Open youyou-128 opened 1 year ago
The pathmap editor allows you to save & load your pathmaps (see the "How to save & load" section here) by copying the current global variable values in the inspector. The actions copied here can be pasted into a rule to load a save. Any global variables with the persist
attribute will be included in the save.
For example:
// Include the players progress as part of the save game!
persist globalvar Number PlayerProgress = 0;
// Global variable containing an array of effects.
globalvar Any[] EffectArray = [];
If the player progresses through the game then saves the game with the action copy, the save will look something like this:
actions {
Global.PlayerProgress = 5;
Global.EffectArray = [Null, Null, Null, Null, Null, Null];
}
The player can load this save by pasting it into an empty rule. However, the PlayerProgress
variable will get overridden with the default value, 0
. To fix this, add a file called ds.toml
to the root of the project and add this line: reset_nonpersistent = true
. This will add some extra code to the workshop output to deal with this.
variables
{
global:
0: __loadPersist -- ostw generated variable: will be True if the player is loading a save.
1: PlayerProgress
2: EffectArray
}
-- ostw generated rule to assign variable defaults
rule("Initial Global")
{
actions
{
-- Assigns defaults as normal.
Set Global Variable(EffectArray, Empty Array);
-- Any variables with the `persist` keyword has their initialization placed inside this If.
-- These will not be given the default value if a save was loaded.
If(Not(Global Variable(__loadPersist)));
Set Global Variable(__loadPersist, True);
Set Global Variable(PlayerProgress, 0);
End;
}
}
ds.toml
is unfortunately another undocumented feature. It allows you to configure your project. Here are the other settings:
entry_point
: Static entry point rather than the current file. (default unset)paste_check_is_extended
: Determines if the __loadPersist
variable is placed in the extended collection. I strongly recommend leaving this to the default. (default false
)log_delete_reference_zero
: Prints an error to the workshop log when you attempt to free up memory with a null class reference. (default false
)c_style_workshop_output
: Uses the newer workshop syntax (Global.x = Global.a + Global.b
) instead of the old version (Set Global Variable(x, Global Variable(a), Global Variable(b))
). (default false
)compile_miscellaneous_comments
: Determines if ostw will add extra comments to the workshop output (ex. rule action count). (default true
)out_file
: Writes the workshop output code to this file. (default unset)optimize_output
: Controls whether the output workshop code is optimized. (default true
)use_tabs_in_workshop_output
(default false
)subroutine_stacks_are_extended
: Determines if the ostw-generated workshop variables used to track a subroutine's outer class reference will be extended. (default false
)todo: get this info on the wiki
I noticed you used the 'persist' keyword in Pathmap, but there's no related documentation in the wiki. Can you tell me what it's used for?