a question about the forest world keys

a question about the forest world keys

Postby sinisa3games » 22 Feb 2018, 21:39

How do the forest world keys work? And is it possible to recreate it?
'Ello
User avatar
sinisa3games
 
Posts: 66
Joined: 08 Feb 2018, 20:45
Location: Right over there

Re: a question about the forest world keys

Postby mteufel » 23 Feb 2018, 14:02

Using scripting. And yes.
SuperTux developer
mteufel
 
Posts: 139
Joined: 03 Jan 2016, 09:27

Re: a question about the forest world keys

Postby manuel » 23 Feb 2018, 15:10

It's a bit more complicated than standard scripting in a level because you have to save information in the savefile, but you can do many things, that effect multiple levels with this mechanic.
manuel
 
Posts: 135
Joined: 19 Sep 2017, 09:03

Re: a question about the forest world keys

Postby WeLuvGoatz » 24 Nov 2018, 20:12

Can someone please explain, in detail, how? Or does someone have a link that leads to how I can recreate this?
I Luv Goatz. You Luv Goatz. WeLuvGoatz!
WeLuvGoatz
 
Posts: 87
Joined: 23 May 2018, 19:15

Re: a question about the forest world keys

Postby manuel » 25 Nov 2018, 14:24

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…
}
manuel
 
Posts: 135
Joined: 19 Sep 2017, 09:03

Who is online

Users browsing this forum: No registered users and 1 guest