Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Variable Syntax

9 years ago

Hey so I looked everywhere on the Help&Info page, but I couldn't find the syntax for variable declaration and accessing variables, at least not clearly. So I have a few questions. I do know java and python languages, but I don't know this one. How would I do this script in this sites language? (below is in java)

int gender = 0;

//if they go to page 1

gender++:

//else do nothing

//then later in the script:

if (gender == 0) System.out.print("she ") ;

else System.out.print("he ");

--

so if gender = 0 then it shows she, and if not it shows he. Also if you can, please explain the basic syntax rules of this language, it's kind of hard to understand without a clear explanation.

Variable Syntax

9 years ago
The entire section titled "Scripting" answers those questions.

If have to declare variables in the variable tab of your storygame before you can use them.

%gender:= 0

%gender := %gender+1

There is no print in this. You have two options to add things to the page: in line scripting and pagescripts. Which you choose depends on where on the page you want the text to appear.

There are only int variables, and there are no loops/arrays. Its very basic functionality, so you need to get creative if you want to do anything complex.

Variable Syntax

9 years ago

For that if statement of yours, you can use script:

IF %GENDER = 0 THEN $PAGETEXT := $PAGETEXT + "she" ELSE $PAGETEXT := $PAGETEXT + "he"

or you can do it more easily using a special syntax directly on the page:

%%GENDER%=%0%she%%%%GENDER%=%1%he%%

Variable Syntax

9 years ago

Wouldn't the first option just show the regular text plus the word "he" or "she" on a line at the bottom?

Sounds like they're wanting to incorporate it in the text, so the second option is the only one that would work. Would get kind of clunky and tedious doing that for every instance of a pronoun, though.

Variable Syntax

9 years ago

The first would work too, as long as all of the page's text is scripted. Definitely wouldn't recommend it unless it's a really variable page, though.

Variable Syntax

9 years ago

Thanks so much! That makes a lot of sense. :D