Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

On Page Scripting: The Bane of My Existence

6 years ago

So I've got two events that are very similar in my story, which have corresponding variables %ZDISINT1 and %ZDISINT2 that start off with a value of 0 and are set to values of 1 via page script when you get to their pages. Later on, I'd like to add some on page scripting that talks about them and in the potential sequences you can encounter the events (as you can get to both events, or just either one and not the other). So I had the idea to set up some more variables: %ZDISINT3, %ZDISINT4, and %ZDISINT5. On the page I want to put in the on page scripting, I put the following code into the page script.

IF %ZDISINT1 = 0 AND %ZDISINT2 = 1 THEN %ZDISINT3:= 1
ELSE IF %ZDISINT1 = 1 AND %ZDISINT2 = 1 THEN %ZDISINT4:= 1
ELSE IF %ZDISINT1 = 1 AND %ZDISINT2 = 0 THEN %ZDISINT5:= 1

And put in the on page scripting of:

%%ZDISINT4%=%1%Text.%% %%ZDISINT3%=%1% Other text.%%More text to separate out the next variable and the last without needing a double space because I don't like how it looks because I'm a filthy pedant.%%ZDISINT5%=%1% Last Text.%%

When I run it through and do both events, nothing comes up on screen, not even a 0. Tried on page scripting inside more on page scripting and that didn't work either (e.g: %%ZDISINT1%=%1%Blah blah%%ZDISINT2%=%1% and blah.%% more blah.%%) If anyone can help me or tell me why I'd be forever in your debt etc etc thanks! :)

(Wordy... but I got there in the end.)

On Page Scripting: The Bane of My Existence

6 years ago
Why do you use so many different variables? Why not just set the same variable to different values?

For starters, I'd check the "show variable on page" box for each of the variables involved so you know their values. Alternatively, you can show the variables by putting %%VARIABLENAME%% on the page for each variable involved.

If that checks out, I'd consider not using the AND statements, as they tend to be kind of wonky.

IF %ZDISINT1 = 1 THEN
BEGIN
IF %ZDISINT2 = 1 THEN %ZDISINT4:= 1
ELSE IF %ZDISINT2 = 0 THEN %ZDISINT5:= 1
END
ELSE IF %ZDISINT1 = 0 THEN
IF %ZDISINT2 = 1 THEN %ZDISINT3:= 1

Provides the same functionality.

On Page Scripting: The Bane of My Existence

6 years ago

Oh yeah, that would be way easier. I suppose I could just set %ZDISINT1 equal to 1 if you come across the first event, then equal to 2 if you encounter both, or equal to 3 if you only encounter the second. Thanks for the help, I'll try it out.

Ed: yeah, works perfectly. Were you sent by the Gods to help people script?