Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

What am I missing about Page Scripts?

one month ago

I have a Page Script that is two simple lines:

%RAND := 1D3
%MOVE := 1D6

To my understanding that should set RAND to a random number between 1-3 and MOVE to a random number between 1-6.  However, the following output line {RAND = %%RAND%%    MOVE = %%MOVE%%} on the page always shows RAND = 0 and MOVE = 1.  MOVE is defined in the Variable list, but RAND is not.  From everything I've looked at this should work. Anyone have any ideas on what I'm missing?

What am I missing about Page Scripts?

one month ago

I also tried wrapping the page script in a BEGIN and END, but that had no effect.

What am I missing about Page Scripts?

one month ago
I don't use page scripts often, but I think they may not adjust variables the same way link scripts do. With the latter it happens when you click and before the page loads.

If anyone uses page scripts extensively I'd like to hear from them though, I'm not sure what it specifically is good for compared to link scripts.

What am I missing about Page Scripts?

one month ago

If I move the exact same two lines into a Link Script going to that page the variables are set as expected (even with the Page Script still in place), so you are correct that Page Scripts apparently do not adjust variables like Link Scripts. My hope with using the Page Script was simplifying the various links throughout the game that go to the same page, so I don't have to worry about forgetting to do the link script for all of them, and I just point the link and it will work.

What am I missing about Page Scripts?

one month ago
Yes, the page scripts seem to run very late, after the text replacement has been done and also after the link options have been decided.

You might want to put this in the link script in the page script or you could use a pagescript like this:

%RAND:=1D3
$PAGETEXT:=$PAGETEXT+"RAND="+%RAND

What am I missing about Page Scripts?

one month ago

Yeah, I've done some more testing and this is accurate.  So if you want to have variable driven text on the page you will need to either do all of that as $PAGETEXT modifications, or set the variables in the link script and use normal in-line references for the on page text.