There was a request for a locking / unlocking - system in scenarios for creation of campaigns.
Here is my first version of my Campaign-Library for Lua.
Usage:Copy the campaign_lib.lua into the directory of your scenario and add
dofile(getSystemMacroValue("$SCENARIO_PATH").."campaign_lib.lua") to your <global> script-area.
<scenario>
...
<scripts>
<global>
dofile(getSystemMacroValue("$SCENARIO_PATH").."campaign_lib.lua")
</global>
...
</scripts>
</scenario>
Now you can use all the new methods.
Name the first scenario of a campaign however you want name the second like the first but add a "_1", for the third a "_2" and so on.
campaign_lib:loadStatus(name)
Loads the saved campaign-variables of the campaign with the name name (name of the first scenario).
This method should be almost always called on the very top of <startup>.
campaign_lib:getStatus(name,index)
Returns the value of the campaign-variable of name with the alphanumerical index index or 0 if the value was neighter set nor loaded.
campaign_lib:setStatus(name,index,value)
Sets the value of the campaign-variable of name with the alphanumerical index index to value.
campaign_lib:saveStatus(name)
Saves the campaign-variables of the campaign with the name name.
campaign_lib:toState(name,index)
Loads the scenario of the campaign name where the number is equal to the value of the campaign-variable of name with the alphanumerical index index.
If index is 0 the first scenario is loaded (the one without any number)
Download-link .7z 768B