Added new syntax for impulse
parent
1ca30fe589
commit
31c0d41e83
20
tfscript.py
20
tfscript.py
|
@ -37,19 +37,36 @@ def firstTypeIn(inputList):
|
|||
def branch(keyName, bindContent, bindType):
|
||||
if bindType == "impulse":
|
||||
return impulse(keyName, bindContent)
|
||||
|
||||
elif bindType == "hold":
|
||||
if isinstance(bindContent, str):
|
||||
return simpleHold(keyName, bindContent)
|
||||
else:
|
||||
return listHold(keyName, bindContent)
|
||||
|
||||
elif bindType == "toggle":
|
||||
return toggle(keyName, bindContent)
|
||||
|
||||
elif bindType == "double":
|
||||
return double(keyName, bindContent)
|
||||
|
||||
elif bindType == "repeat":
|
||||
return repeat(keyName, bindContent)
|
||||
|
||||
def impulse(key, instruction):
|
||||
if isinstance(instruction, list):
|
||||
instruction = ';'.join(instruction)
|
||||
|
||||
allInstructions = []
|
||||
|
||||
for indivCmd in instruction.split(';'):
|
||||
allInstructions.append(impulseShortcuts(indivCmd))
|
||||
|
||||
instruction = ';'.join(allInstructions)
|
||||
|
||||
return f'bind {key} "{instruction}"\n'
|
||||
|
||||
def impulseShortcuts(instruction):
|
||||
splitCommand = instruction.split(' ')
|
||||
cmd = splitCommand[0]
|
||||
shortcuts = {
|
||||
|
@ -64,7 +81,6 @@ def impulse(key, instruction):
|
|||
break
|
||||
instruction = ' '.join(splitCommand)
|
||||
|
||||
|
||||
restOfCmd = ' '.join(splitCommand[1:])
|
||||
if cmd == "voice":
|
||||
instruction = voice(restOfCmd)
|
||||
|
@ -72,7 +88,7 @@ def impulse(key, instruction):
|
|||
elif cmd == "build" or cmd == "destroy":
|
||||
instruction = f"{cmd} " + expandBuildings(restOfCmd)
|
||||
|
||||
return f'bind {key} "{instruction}"\n'
|
||||
return instruction
|
||||
|
||||
def voice(keyword):
|
||||
keyword = keyword.lower()
|
||||
|
|
Loading…
Reference in New Issue