Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Variable Influenced Page Text

3 years ago

I'm trying to set up a page where the text is different depending on what the variable's number is (The difference is based on whether or not the character has a flashlight). Would I accomplish this via an IF/THEN statement using the Source button in the editor?

Variable Influenced Page Text

3 years ago
We're talking changing all the text on the page?


I ended up doing that not too long ago with:

IF %VAR = 1 THEN $PAGETEXT := "Text on page."
IF %VAR = 2 THEN $PAGETEXT := "Text on page."

Stuff between the quotations can be annoying if you want dialogue (since you then need to put the html entities for the quotes to have it not break and display correctly). I done it once but readability goes down when editing which is annoying, so I'd say just make a separate page (or maybe there's a better way I'm not familiar with?).


Anyway, that goes in the page script box, you get to it with the blue := sign next to the page title. If you don't see this button, go to story properties and [change editor features], and turn up the toggles so you can see everything.

Being able to access page scripts and link scripts is very helpful when you want to use variables for stuff, since only being able to do on-page scripting has its limits.


Anyway, I look forward to someone more knowledgeable showing how they do this, aha.

(Also, not sure if RTE messes with scripting boxes, I think they're all source automatically tho. At any rate, I don't think IF THEN works when used in page source.)

Variable Influenced Page Text

3 years ago

Thanks for the help. There's a few more pieces I need to add to the mechanic, but it works.

Variable Influenced Page Text

3 years ago
Or just use on page scripting.

%%VAR%=%1%TEXT HERE%%

It looks kind of ugly, but you can just copy and paste it right into the story for as many variables as you have and just plug in new text. I find it more versatile than $PAGETEXT since it's easy to use it to alter the story anywhere and in multiple places instead of just before or after the main block of text.

Variable Influenced Page Text

3 years ago
I don't purely prefer on page scripting because if I had something like:

%%VAR1%=%1%Something happens.%%

%%VAR2%=%1%Something else happens%%. Text.

And VAR1 was not 1, then I'd have a blank line at the top of the page. (Although I guess it is possible that I messed up something else to cause that blank line...)

Regardless, on page scripting is definitely very nice.

Variable Influenced Page Text

3 years ago
You just put them together in a block once you're done editing. The blank lines are only there if you leave in blank lines.

%%VAR1%=%1%Text.%%%%VAR1%=%2%Text%%%%VAR1%=%3%Text.%%

And so on. Like I said, it's pretty ugly, but I only collapse it together once I'm done with it and have tested it already. This is also how you display a name chosen by the player and so on so there's really not an issue with spacing.

Variable Influenced Page Text

3 years ago
I thought you can only block together the same variable?

Although I suppose if I've got two variables, I can just combine them into a third before the page loads, and use the third variable for the blocking.

Variable Influenced Page Text

3 years ago
Look again, the scripts aren't combined, all I did was remove unnecessary spaces.

Variable Influenced Page Text

3 years ago
I'm not supposed to be blind!

Alright, I'll have to try on page scripting next time I'm trying to cram things on one page, heh.