import time
import keyboard
Commands = []
Command = {}
RawCommand = ""
repeat = 0
while True:
Command.update({ "RawCommand": input("Command? ")})
Command.update({ "Times": int(input("How many times? (NUMBER!!) "))})
if Command["RawCommand"] == "Done":
Command.clear()
for LoopCommand in Commands:
RawCommand = LoopCommand["RawCommand"]
while LoopCommand["Times"] != 0:
if RawCommand == "Walk":
keyboard.press("W")
time.sleep(0.25)
keyboard.release('W')
if RawCommand == "Jump":
keyboard.press(" ")
time.sleep(0.04)
keyboard.release(' ')
LoopCommand["Times"] = LoopCommand["Times"] - 1
Commands.clear()
else:
Commands.append(Command)
print(Commands)
The code is meant to take commands I give it and run them for a game. However, the for
loop that's meant to comprehend and run commands just uses the "Done" command used to initiate the running of commands instead of the actual table of commands.