Where does CS store its variables


#1

I wanted to know if anyone knew where the variables you set (the global ones anywho) are stored, that way, with that information, using the *script command, advanced users could implement custom functions, for example determining the picture of the enemy that appears off of a dice roll that CS ran previously to determine the enemy type (<- This particularly would be my current area of interest since the CS *image command does not process variables in ${ }'s).


Now you can extract letters/numerals in ChoiceScript
#2

stats["< name of variable here >"]

At least that’s what’s been working for me!


#3

Look for the scene.js file and open the file in notepad or notepad ++. Then scroll down to the very end of the file and you have a list of commands available in the game. You can add the new commands in the list there.


#4

That’s just a list of valid commands, you’d still have to write a JS function to implement the new command.

But yes, stats.??? for globals and temps.??? for temp variables.


#5

If you’re wanting to have different images appear depending on a dice roll, you can do something like

*create diceroll ""

*set diceroll 2

*if diceroll = 1
    *image 1.jpg

*elseif diceroll = 2
    *image 2.jpg

unless I’m misunderstanding what you’re wanting?


#6

That is what I want to do but, I’d rather forgo having to type out a bunch of extra commands and instead simply have the (modified) *image command pick out the enemy from a variable. So while I’d still have to write the *rand and *if “insert number here” *set enemy “whathaveyou”, I wouldn’t have to add an *image command to every *if command, and simply have it dynamically load up an image based on the variable. Normally this would not be overmuch of a problem if it was a simple enemy system, and it wouldn’t be overmuch to type up, but if you’re adding extra layers like enemy position and wanting to have the enemy visually displayed in that position (e.g. Rearguard right, or Vanguard center), the possibilities to factor in start to pile up.

@CJW and @Gantron Er… pardon? You’ve lost me already, lol. Stats? Is this a command? Or something else?


#7

*script alert(this.stats.nameofvar);


#8

I think I understand:
*script “Your-function-which-changes-variables-here”(this.stats.nameofvar) rather than alert… etc., correct?

Would something as simple as

nameofvar = “value”;

in the function suffice to change the variable manually?


#9

*script this.stats.nameofvar = “value”;


#10

*script is not a recommended way of doing anything; when people have a common need for *script, I try to convert it into a proper feature.

In that case, that’s what I’ve done here. It was a one-line fix in ChoiceScript to make *image support ${}, and now it does, in the latest version of ChoiceScript up on github.

*image ${selected}.png

Enjoy!


#11

I use subroutines for this kind of thing. I type out every exhausting possibility once, then refer the game back to the list to fill in the variable needed. Just use *gosub_scene to send it to a file that sets the correct image title for “monster=___”.

…Now that @dfabulich has added an official way to do it, his way sounds much easier, but you can use this technique for other things that are irritating to fill in by hand.