Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Declaring variables

one year ago

If you are using a given variable in a page script or in the page body, do you need to define that Variable in the variables list for the storygame, or can you just use them on the fly if you don't need them to persist page to page?

Declaring variables

one year ago

You can make up a variable on the fly. It will default to zero and any value it's given will persist like any other variable.

Declaring variables

one year ago

This script only outputs 0, which leads me to think I am not setting the %TEXTADD variable properly.  Can someone trouble shoot this simple thing for me?  According to everything I have looked at in the way of scripting articles, this should be functional, and it passes validation.

IF %RUNFROM > 1 THEN 
%TEXTADD := "Fleeing from the moving shadows, you pelt through alleyways and parking areas.  Several times you trip or stumble over piles of snow or spots of ice, yet even so whatever they are that is chasing you never quite catch you.  Eventually you realize that you haven't seen them for a minute or two.  Taking a couple more turns, you emerge suddenly at a familiar intersection.<br/><br/>" 
ELSE
%TEXTADD := "You head down towards the old industrial district.  You paused for a moment to take a couple shots of the shadowy buildings against the backdrop of the river and rest of the city on the other side.  As you walk you start to consider some of the history of the area.<br/><br/>"
$PAGETEXT := %TEXTADD + $PAGETEXT

 

The output is always 0 + $PAGETEXT.  I've also tried just referencing the variable in the text block (%%TEXTADD%%) but get the same output.

I've tested and confirmed that I can change %TEXTADD to a numeric value and it outputs as expected.

Declaring variables

one year ago

So I guess you just can't put text in variables?  That is an odd limitation, although I guess it is an easy way to eliminate people trying to do injection attacks on the DB.

Reworked the check to drop adding the text to a variable and just adjust $PAGETEXT in the expression and it works as I would expect it to.

IF %RUNFROM > 1 THEN 
$PAGETEXT := "Fleeing from the moving shadows, you pelt through alleyways and parking areas.  Several times you trip or stumble over piles of snow or spots of ice, yet even so whatever they are that is chasing you never quite catch you.  Eventually you realize that you haven't seen them for a minute or two.  Taking a couple more turns, you emerge suddenly at a familiar intersection.<br/><br/>" + $PAGETEXT
ELSE
$PAGETEXT :=  "You head down towards the old industrial district.  You paused for a moment to take a couple shots of the shadowy buildings against the backdrop of the river and rest of the city on the other side.  As you walk you start to consider some of the history of the area.<br/><br/>" + $PAGETEXT

Declaring variables

one year ago
You can use on page scripting too, that can be easier if you're just changing a line or two since you can dump it right in with the rest of the story text.

It would look like,

%%RUNFROM%>%1%text goes here%%
%%RUNFROM%<%1%alternate text%%

Then the rest of the page will show up normally.

You can cram a bunch of these in a big block to prevent any weird line breaks or spaces in the game text, I just separated them for reading. This is the way to switch names or pronouns around mid sentence too.

Declaring variables

one year ago

Is there any particular pro/con to doing it one way or the other?

Declaring variables

one year ago
On page scripting feels like an easier way to make many small changes, but they accomplish pretty similar things afaik.