diff --git a/tfscript.py b/tfscript.py index 6c324bc..b4f61a3 100644 --- a/tfscript.py +++ b/tfscript.py @@ -38,11 +38,64 @@ def branch(keyName, bindContent, bindType): return repeat(keyName, bindContent) def impulse(key, instruction): + splitCommand = instruction.split(' ') + cmd = splitCommand[0] + shortcuts = { + "primary": "slot1", + "secondary": "slot2", + "melee": "slot3" + } + if cmd in shortcuts: + for sc, expansion in shortcuts.items(): + if cmd == shortcut: + splitCommand[0] = expansion + break + instruction = ' '.join(splitCommand) + + + restOfCmd = ' '.join(splitCommand[1:]) + if cmd == "voice": + instruction = voice(restOfCmd) + + elif cmd == "build": + instruction = "build "+expandBuildings(restOfCmd) + + elif cmd == "destroy": + instruction = "destroy "+expandBuildings(restOfCmd) + return f'bind {key} {instruction}\n' +def voice(keyword): + keyword = keyword.lower() + + allLists = [ + ["medic", "thanks", "go", "move up", "go left", "go right", "yes", "no", "pass to me"], + ["incoming", "spy", "sentry ahead", "teleporter here", "dispenser here", "sentry here", "uber (ask)", "uber (ready)"], + ["help", "battle cry", "cheers", "jeers", "positive", "negative", "nice shot", "good job"] + ] + + for menu, voiceList in enumerate(allLists): + for selection, shortcut in enumerate(voiceList): + if keyword == shortcut: + return f'voicemenu {menu} {selection}' + +def expandBuildings(building): + buildingNums = { + "dispenser": "0 0", + "entrance": "1 0", + "exit": "1 1", + "sentry": "2 0" + } + for shortBuild, num in buildingNums.items(): + if building == shortBuild: + return num + def simpleHold(key, instruction): # This isn't quite right, fix later! - return f'bind {key} +{instruction}\n' + if instruction[0] != '+': + return f'bind {key} +{instruction}\n' + else: + return f'bind {key} {instruction}\n' # return f'placeholder for {key} (single instruction hold)\n' def listHold(key, options):