Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

First time with variables

10 years ago

I'm experimenting with variables to show different text depending on previous choices, and hit the first wall.

Lets say I have one page where you can choose to be and elf or a hobbit, and certain pages will change to reflect this (single words for now)

How should I script it to change this single word in the page?

First time with variables

10 years ago
Link 1 "Elf"
Link 2 "Hobbit"

In link 1, put:
%RACE := 1;

In link 2, put:
%RACE := 2;

Then in the other pages, put:

IF %RACE = 1 THEN
$PAGETEXT = $PAGETEXT + "ELF"

IF %RACE = 2 THEN
$PAGETEXT = $PAGETEXT + "Hobbit"

First time with variables

10 years ago

If it's just a single word replacement, wouldn't on-page code be simpler? After the %RACE variable is set, you could put %%RACE%=%1%elf%%%%RACE%=%2%hobbit%% directly in the page rather than in the script whenever the variable needs to be displayed.

First time with variables

10 years ago

Thank you. Your way is simpler, and it worked like a charm.

First time with variables

10 years ago
It would be. Yes.

First time with variables

10 years ago

Thanks you.