When you first make a variable does it have to be created in the startup file or can you create them in any file??
It needs to be created in the startup file.
ok thanks, I thought so…another thing…if i make a label in one file…can I use the same label name in another file yet for another scene? if that makes sense…
btw…I think everyone should change their pic to some kind of bird… O.o … lol
Yes you can use the same label name in two different files.
And yes they should.
That’s not the whole truth. If you want permanent variables, you have to create them in startup. But if you only need to call on a variable in one single scene, then you can use a temp (temporary variable) instead, which you create inside the scene in question by writing *temp instead of *create.
@MutonElite I didn’t want to over complicate things by going into temp variables.
Variables made with the *create command can only be created in the startup.txt page. They will work in all scenes. These are the variables you want to use most of the time.
Temp variables are different and they do have their uses too. You can read more about them https://www.choiceofgames.com/make-your-own-games/important-choicescript-commands-and-techniques/ and http://choicescriptdev.wikia.com/wiki/Temp
so like this…??
*temp dead false are you dead? *choice #yes *set dead true #no *if dead = true you are not alive!!
For temp variables, yes.
They’re good for keeping track of things in scenes which you don’t need for the entire game.
Just remember that temp variables disappear as soon as you leave a certain scene. Even if you come back later for some reason, you have to declare and set them again.
A lot of people who are newer to coding might wonder why you’d ever need to use temporary (I use the word “local”) variables in the first place. I’m not sure if it really matters all that much specifically in the ChoiceScript world since the games are generally small in size and easy to load, but here’s why you need to remember the difference:
Permanent/Global variables can only be created in the “startup” file and are used throughout all scenes and are relevant to more than one scene. You might use a variable like this for a relationship status or the player’s gender, etc.
Temporary/Local variables can be created anywhere and are used for things only relevant in their respective scene. These might be used for whether or not you invited some character Kim along with you to the movies, because you’d need the variable since maybe she agrees with you on what movie to see and you outvote the others, but only if she comes. This variable wouldn’t be needed in any other scene.
This is important because in most cases, having too many global variables can cause serious lag and worsen loading times. Again, I’m not sure how relevant this is in CS, but it’s a good habit to get into even if it only helps the speed a little bit.
Temps are cool if you just need a variable for a specific scene, but you won’t ever need it again. It also helps because unlike create, you don’t have to specify a value.
*temp dead Are you dead? *fake_choice #Yes. *set dead true #No. *set dead false *if dead You lose! *finish You win! *finish