Globals Files [Possible Feature] - Paramecium13/LSN GitHub Wiki

Globals files store variables whose state is preserved by saves (and thus across executions) and which can be accessed by other files. For an LSN resource, quest, or script file to access variables in a globals file, they must request runtime linkage of it through the '#using' directive.

Watched Variables

Used by rules... ... Persistence: Connections between rules and watched variables are not persistent through serialization. They must be reestablished when the rules are deserialized.

Linkage and Loading

Runtime linking of globals files will differ from runtime linking of resource files in that the interpreter will have to load the saved state of the variables and possibly update them.

A basic recommended architecture for dealing with globals files:

  • Globals object files: Stores the names, types, and initial values of variables and the logic for goal variables.
  • Globals state (.net object): Stores the state of the variables of a globals file.
  • Save game files: Stores the globals state for each globals file and all other save game data for the game.
  • Globals cache (.net object): Stores globals state objects at runtime and controls all access to them. Provides current values to the interpreter and receives updated values from it. When a goal variable is moved past one (or more) of its goals by the interpreter, the cache notifies the interpreter and either has it execute the goal(s) or pauses it, spawns a new interpreter to execute the goal(s), then resumes it.