Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Nesting On-Page Variables?

9 years ago

Is it possible to add more than one condition to an on-page variable? I'm having some trouble with getting things to display properly due to the order in which Global Page, Global Link, Page, and Link scripts are parsed.

Being able to use an on-page variable would neatly side-step the issue without requiring me to go back and re-script everything on my global pages.

If it's not possible, does anyone have any ideas about how to squeeze in some text between the actual $PAGETEXT of the page, and the $PAGETEXT added by the global scripts? I need them to parse in a specific order (namely, I need short sentences like 'You inflicted X damage' to appear AFTER the user interface added by the global page script, but before the text on the page and the second half of the user interface also added by a global page script.)

Nesting On-Page Variables?

9 years ago
You mean like nested conditions?

So far as I'm aware you can't, however you can cheat by making an addition variable and setting its value to something dependent on your conditional variables, then using that variable on page instead.

In order for this to make it to the on page part correctly though, you'd need to set the value either on a page before or the link before.

Nesting On-Page Variables?

9 years ago

Rats. So I'll have to re-script stuff anyway.

Thanks for the additional variable tip though - it's still a lot neater than copy-pasting my entire UI script onto every single page in the game.

If I'm understanding it correctly, would it go something like this?

BEGIN

IF %VAR1 = 0 AND %VAR2 = 0 THEN

%NEWVAR := 0

ELSE IF %VAR1 = 0 AND %VAR2 = 1 THEN

%NEWVAR := 1

ELSE IF %VAR1 = 1 AND %VAR2 = 0 THEN

%NEWVAR := 2

ELSE IF %VAR1 = 1 AND %VAR2 = 1 THEN

%NEWVAR := 3

END

Then on page just use: %%NEWVAR%=%3%Both VAR1 and VAR2 are 1%%

Nesting On-Page Variables?

9 years ago
Yep. Though you only need BEGIN/END if something is multiple line, so technically all that can look like:

IF %VAR1 = 0 AND %VAR2 = 0 THEN %NEWVAR := 0
ELSE IF %VAR1 = 0 AND %VAR2 = 1 THEN %NEWVAR := 1
ELSE IF %VAR1 = 1 AND %VAR2 = 0 THEN %NEWVAR := 2
ELSE IF %VAR1 = 1 AND %VAR2 = 1 THEN %NEWVAR := 3

Unless that is all encompassed under some other IF condition.