Using goto_scene and variables

Is it possible to use *goto_scene (variable)? An example of this would be;

*temp variable1 “scene4”
*goto_scene “${variable1}”

The text file’s name would read “scene4.txt”.

Obviously this makes it harder than it has to be but in my game the scenes will be in a random order. I’ve solved this with a ton of if commands but I was curious.

Please note. I am not having trouble with the randomization of the scenes, I have all of that figured out.

Ex:
*if variable1 = “scene”
-*goto_scene scene
*if variable1 = “scene2”
-*goto_scene scene2

*if variable2 = “scene”
-*goto_scene scene
Etc. etc. …

Judging by your example I would say it’s probably possible, but generally what I do in that case would be a text variable like

*if variable1= “leftdoor”
-*goto_scene leftdoorscene

I’m not sure why you would need to name it the particular scene name. I would find it confusing personally, but if it works for you then I don’t see why not

You can do that without variables now.

*goto_scene chapter_one label_name

Would send the player to chapter_one and to the name of the label you mention.

3 Likes

In using the goto_scene command you may need to make sure the variable is always defined for the script to work. I’m still learning but if at anytime the variable is not defined the script would crash (i think)

I think there used to be a “gotoref” command, but it’s easier now than I think you’re making it - in the 2nd page (Advanced Choicescript) in the documentation:

Goto a label by name:
*temp superpower “invisibility”
Your super power is:
*goto {superpower}
flight!
*finish
*label invisibility
invisibility.

So if you declare a variable *create magicscene “pooloftears”, *goto {magicscene} will go to pooloftears. If later you *set magicscene “corridorofdoors” it will change {magicscene} to that.

I haven’t used this, but this seems to be the way to do it from the documentation. You could, of course, use a random to vary the scene.

In the wiki there’s a *goto_random_scene command which lets you list a number of scenes the text can split to. Limitation of this is if you recurse it will pick a random scene each time and won’t re-use them. If the random scene list is exhausted, it falls out to the next scene instead of picking a random one from the list.

@Hanon_Ondricek I swear if this is true… I spent an hour on this and thought of this but decided that it wasn’t worth trying because it didn’t seem like it would work.

I’m away from home but I will try it when I get home.

1 Like

Damn, I just wrote exactly what @Hanon_Ondricek has already told you. Sorry I read this post hours ago but wanted to test the code before I replied.

Just make sure you leave out the $ sign when you write the variable for:

*goto {variable}

and it will work fine

Ok thank you so much! I can’t believe I tried everything but that.

Tell me when your next update comes out for the followers I can’t wait to see where this goes. And again if any of you need any help don’t be afraid to ask!