Narrare
The Narrare global script contains variables, enums, signals, and functions used throughout a Narrāre game. It can be accessed with Narrare from anywhere in the project. For example:
Narrare.say("Hello world!");
Enums
Direction
Direction {NONE, NORTH, NORTHWEST, WEST, SOUTHWEST, SOUTH, SOUTHEAST, EAST, NORTHEAST, UP, DOWN}Indicates a cardinal direction, as well as up or down. Typically used to refer to an exit or entrance to a Room.
Signals
These signals can be connected to from anywhere in the project.
say_something
say_something(message: String)Indicates that a String 'message' should be outputted to the player. This will typically be connected to by the interface, but could be used for other purposes as well.
clear_output
clear_outputIndicates that the output should be cleared.
done_writing_to_output
done_writing_to_outputThis should be emitted when the interface is done writing something to the output. You do not need to do this if you will not be using this signal.
done_writing_to_input
done_writing_to_inputThis should be emitted when the interface is done writing something to the command input. You do not need to do this if you will not be using this signal.
prompt_changed
prompt_changed(is_prompt: bool)Emitted when a change is made to the Narrare.current_prompt variable; if Narrare.current_prompt has been set to null, is_prompt will be false, otherwise it will be true.
input_request_changed
input_request_changed(is_input_request: bool)Emitted when a change is made to the Narrare.current_input_request variable; if Narrare.current_input_request has been set to null, is_input_request will be false, otherwise it will be true.
Variables
map
map: MapThe current Map. This should be set by the game when a Map node is loaded.
previous_text_displayed
previous_text_displayed: StringThe last meaningful text to be output to the player. This text is saved when calling
Narrare.save(), and will be output when that save is loaded. It is generally advised that you only set this variable when something useful is output, like the description of a room or the result of interacting with an interactable.
data_saved
data_saved: boolShould be set to
trueonly if the game state has not been changed since the last time the game was saved. If it isfalse, a confirmation prompt will be shown when loading a save. Generally you won't have to interact with this variable yourself.
current_prompt
current_prompt: PromptIf you want to present the player with a Prompt, this variable should be set to that Prompt. Otherwise, it should be null. Changing this variable emits the
prompt_changedsignal.
current_input_request
current_input_request: InputRequest**If you want to present the player with an InputRequest, this variable should be set to that InputRequest. Otherwise, it should be null. Changing this variable emits the
input_request_changedsignal.
Functions
say
say(message: String) -> voidA convenience function. Emits the
say_something(message)signal, indicating thatmessageshould be output to the player.
clear
clear() -> voidA convenience function. Emits the
clear_outputsignal, indicating that the output should be cleared.
save
save(save_name: String = "-----") -> intAttempts to save the game. Saves are saved to the
user://Savesdirectory. Saves are given a namesave_namewhich will be displayed when callingNarrare.list_saves(). The returned int is the number of the save which will be used to access it byNarrare.load_save(save_number: String). It will return -1 if the save failed.
list_saves
list_saves() -> StringReturns in String format a list of saves in the
user://Savesdirectory.
load_save
load_save(save_number: String) -> DictionaryAttempts to load a saved game from theuser://Savesdirectory by save_number. Note that save_number is given as a String; this is because this will be user input. If this function succeeds, the game state will be changed to reflect the data in the loaded save. Returns a Dictionary of the form{"err": Error, "out": String}where err is a Godot Error enum value and out is a resulting string to output to the user. IfNarrare.data_savedisfalse, a confirmation Prompt will be given to the user before the load goes through.