Beispiel #1
0
def get_player_name(callback):
    global name_parsed
    name_parsed = False
    engine.clear_scripter()
    engine.insert_to_scripter(
        "print(\"" + engine.get_dialogue(level_name, "print_name_string") +
        "\")")
    engine.enable_py_scripter()
    script_api = {"print": lambda text: name_parser(text, callback)}

    stc = ScriptStateContainer()

    stc.set_script_name("Monty")
    engine.register_input_callback(
        engine.INPUT_RUN, lambda: stc.run_script(
            script_api, engine, callback=lambda: handle_run()))
    engine.register_input_callback(engine.INPUT_HALT, stc.halt_script)
Beispiel #2
0
engine.show_py_scripter()
engine.set_py_tabs(1)
engine.enable_py_scripter()
engine.insert_to_scripter(
    "#Message to all Pyland Citizens:\n#- Use the arrow keys to select menu options\n#- Press 'Enter' to select an option\n#- Use the following command to load a saved game:\nload_game(\"\")"
)


def load_game(save_name):
    save_data = engine.get_player_data(save_name)
    engine.set_player_name(save_name)
    engine.change_map(save_data["current_map"])


#Let the player run python scripts in the menu...
stc = ScriptStateContainer()
script_api = {"load_game": load_game, "load_map": engine.change_map}
stc.set_script_name("Menu")
engine.register_input_callback(
    engine.INPUT_RUN, lambda: stc.run_script(script_api, engine)
)  ##TODO: could provide some customer easter egg api's in the menu? :) (cheatcodes?)
engine.register_input_callback(engine.INPUT_HALT, stc.halt_script)


#The actual menu implementation...
def set_current_state(next_state, callback=lambda: None):
    """ A simple callback that is run to set the current menu state after the camera has finished moving """
    global current_state
    current_state = next_state
    engine.add_event(callback)