Skip to content

Commit

Permalink
M E R G E (wow a creative name) (#36)
Browse files Browse the repository at this point in the history
* a

* changed signatures of functions and attributes to reflect on snake_case. please change your code to support the refactor. also corrected some spellings.
snake_case: all lowercase, underscore separated.

* plugin time!

* changed stuff, and added example testing thing

* what

* something

* up the version

* did stuff

* idk man
  • Loading branch information
HellishBro authored Nov 17, 2023
1 parent 3863c28 commit b1c5416
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 216 deletions.
125 changes: 58 additions & 67 deletions examples/moving.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,64 @@ class MovementPlugin:
def __init__(self, bot: lodestone.Bot):
"The injection method"
self.bot = bot
self.internal_bot = bot.bot

@bot.add_method()
def forward(hold_time=1):
"""
Holds the "W" key for hold_time seconds
"""
self.bot.set_control_state("forward", True)
time.sleep(hold_time)
self.bot.set_control_state("forward", False)

@bot.add_method()
def backward(hold_time=1):
"""
Holds the "S" key for hold_time seconds
"""
self.bot.set_control_state("back", True)
time.sleep(hold_time)
self.bot.set_control_state("back", False)

@bot.add_method()
def left(hold_time=1):
"""
Holds the "A" key for hold_time seconds
"""
self.bot.set_control_state("left", True)
time.sleep(hold_time)
self.bot.set_control_state("left", False)

@bot.add_method()
def right(hold_time=1):
"""
Holds the "D" key for hold_time seconds
"""
self.bot.set_control_state("right", True)
time.sleep(hold_time)
self.bot.set_control_state("right", False)

@bot.add_method()
def jump():
"""
Make the bot jump
"""
self.bot.set_control_state("jump", True)
time.sleep(0.2)
self.bot.set_control_state("jump", False)

@bot.add_method()
def start_sneak():
"""
Make the bot start sneaking
"""
self.bot.set_control_state("sneak", True)

@bot.add_method()
def stop_sneak():
"""
Make the bot stop sneaking
"""
self.bot.set_control_state("sneak", False)

@bot.add_method()
def halt():
"""
Halts all movement
"""
self.bot.clear_control_states()

def forward(self, hold_time=1):
"""
Holds the "W" key for hold_time seconds
"""
self.bot.set_control_state("forward", True)
time.sleep(hold_time)
self.bot.set_control_state("forward", False)

def backward(self, hold_time=1):
"""
Holds the "S" key for hold_time seconds
"""
self.bot.set_control_state("back", True)
time.sleep(hold_time)
self.bot.set_control_state("back", False)

def left(self, hold_time=1):
"""
Holds the "A" key for hold_time seconds
"""
self.bot.set_control_state("left", True)
time.sleep(hold_time)
self.bot.set_control_state("left", False)

def right(self, hold_time=1):
"""
Holds the "D" key for hold_time seconds
"""
self.bot.set_control_state("right", True)
time.sleep(hold_time)
self.bot.set_control_state("right", False)

def jump(self):
"""
Make the bot jump
"""
self.bot.set_control_state("jump", True)
time.sleep(0.2)
self.bot.set_control_state("jump", False)

def start_sneak(self):
"""
Make the bot start sneaking
"""
self.bot.set_control_state("sneak", True)

def stop_sneak(self):
"""
Make the bot stop sneaking
"""
self.bot.set_control_state("sneak", False)

def halt(self):
"""
Halts all movement
"""
self.bot.clear_control_states()


if len(sys.argv) < 3 or len(sys.argv) > 5:
Expand Down
Loading

0 comments on commit b1c5416

Please sign in to comment.