df.Repetition(df.Choice(None, rules.digitMap), min=0, max=10) ], name="n2", ) num2 = df.Modifier(numrep2, rules.parse_numrep) debris = { "(stones | rocks)": constants.STONE, "(wood | twigs)": constants.TWIG, "weeds": constants.WEEDS, "debris": "debris", } mapping = { "<direction_keys>": objective.objective_action(objective.HoldKeyObjective, "direction_keys"), "<direction_nums> <n>": objective.objective_action(objective.MoveNTilesObjective, "direction_nums", "n"), "start swinging [tool]": objective.objective_action(objective.HoldKeyObjective, constants.USE_TOOL_BUTTON), "[equip] item <positive_index>": df_utils.async_action(game.equip_item_by_index, "positive_index"), "equip [melee] weapon": df_utils.async_action(game.equip_melee_weapon), "equip <items>": df_utils.async_action(game.equip_item_by_name, "items"), "nearest <items> [<positive_index>]": objective.function_objective(go_to_object, "items", "positive_index"), "jump <direction_nums> [<positive_num>]":
import game, server, menu_utils, df_utils, items, objective from srabuilder import rules import functools import dragonfly as df MUSEUM_MENU = "museumMenu" mapping = { **menu_utils.inventory_commands(), "pan <direction_keys>": objective.objective_action(objective.HoldKeyObjective, "direction_keys"), } def load_grammar(): extras = [ df_utils.positive_index, df_utils.positive_num, df.Choice("direction_keys", game.direction_keys), df.Choice("direction_nums", game.direction_nums), ] grammar = menu_utils.build_menu_grammar(mapping, MUSEUM_MENU, extras=extras) grammar.load()
def commands(locs): import server commands = {} for loc in locs: for cmd in loc.commands: if cmd in commands: raise ValueError(f"Duplicate location {cmd}") commands[cmd] = loc return commands mapping = { "go to <locations>": objective.objective_action(objective.MoveToLocationObjective, "locations"), } @menu_utils.valid_menu_test def is_active(): return game.get_context_menu() is None def load_grammar(): import df_utils from srabuilder import rules names = get_locations() locs = [] for name in names: