The levels probably have to be packed in the addon-format to test it, but I am not certain…
This is copied and shortend from the keys in the forest world.
So,
you need this file in the same folder where your levels are. You can name it whatever you like, but I recommend calling it "default.nut", as it will be imported automatically with this name.
- {l Code}: {l Select All Code}
if(! ("your_name" in state))
state.your_name <- {}
foreach(name in ["name1","name2","name3"]){
if(! (name in state.your_name))
state.your_name[name] <- false;
}
function settotrue(name){
state.your_name[name] <- true;
}
This will write something into your savefile. You can find it at "supertux2/profile1/your-levelset-id.stsg". (If you are using a different profile, open this profile instead.)
You can name "your_name" as whatever you want, as long as it contains only letters, numbers or _ or - . It must always have the same name where I use "your_name". For "name1", "name2" and so on (and for settotrue) it is the same. You can add more things between these brackets [ ] like this.
If you change something here after runnng it once, it will not correct the savefile, as it already finds something that is called "your_name". So you need to delete the section with "your_name" from the savefile again.
This should create something at the end of your savefile that looks like this:
- {l Code}: {l Select All Code}
("your_name"
(name1 #f)
(name2 #f)
(name3 #f)
)
You can now run settotrue("name1") in a script in your level. You can exchange "name1" with any value you want to set to true. You are then able to use:
- {l Code}: {l Select All Code}
if(state.your_name.name1){
Some scripting here…
}
or if you want to test whether it is not activated yet:
- {l Code}: {l Select All Code}
if(state.your_name.name1 <- false){
Some scripting here…
}