Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Dice Roll Link Script Not Working

6 years ago

Hello, I'm trying to script a link so that it takes the player to different pages depending on what number they get. When validate it, it's fine, but when I play through I get an error. This is my script:

%RAND:=1D6
IF 0<%RAND<4 THEN $DEST:=@P80
ELSE IF %RAND= 4 THEN $DEST:=@P81
ELSE IF %RAND= 5 THEN $DEST:=@P81
ELSE IF %RAND= 6 THEN $DEST:=@P82

I've tried many combinations, and don't know what's going wrong. If you could help I'd be grateful! 

Also, is there any way to add text using the $PAGETEXT variable depending on the last page the player was on? Would you put into the page script something like: IF $LASTPAGE = @P50 THEN $PAGETEXT:= $PAGETEXT + "Text here" 

EDIT: Just thought of something else. Could you just add another variable and set it's limits as either 1 or 0 (say %VAR), and when they've been to a page that you want to cause a change in the text of another page, you just set script %VAR:=1. Then, on the page with the text you want to alter, Put a simple IF %VAR = 1 THEN  $PAGETEXT:= $PAGETEXT + "Text here" ?

 

Dice Roll Link Script Not Working

6 years ago
You can't do IF 0<%RAND<4. You would have to do %RAND > 0 AND %RAND < 4

However we already know RAND is going to be more than 0, so that check isn't needed.

%RAND:=1D6
IF %RAND< 4 THEN $DEST:=@P80
ELSE IF %RAND= 4 THEN $DEST:=@P81
ELSE IF %RAND= 5 THEN $DEST:=@P81
ELSE IF %RAND= 6 THEN $DEST:=@P82

Try that.

Dice Roll Link Script Not Working

6 years ago
Also yes to both your questions. You may want to look into on-page scripting to add text though, as it's more flexible.

You'd also have to make a variable to keep track of the last page, as the system doesn't do that natively.

Dice Roll Link Script Not Working

6 years ago

Thanks, you're a babe:)

Is there any way to remove some text on page given a set of circumstances, e.g using the $PAGETEXT variable minus something?

Maybe like: %IF%VAR%=%1%THEN%$PAGETEXT%:=%$PAGETEXT%-%"Text on page by default"%

(Not sure if you can use IF THEN statements in On Page scripting but I assume you can. Also not sure if I've written that properly but I hope you get the general jist of it)

 

Dice Roll Link Script Not Working

6 years ago
On page scripting if statements are implicit.

%%VAR%=%1%Banana%%

Means if var = 1 then the text "Banana" will show up on the page, where ever the code is located. So the follow put on a page:

The fruit is a %%VAR%=%1%Banana%%.

Will show "The fruit is a Banana" if var is equal to 1. If var is not equal to 1, it would show "The fruit is a ", with no banana showing since the statement is not true. You can also chain these statements, assuming you're checking the same variable. For example:

The fruit is a %%VAR%=%1%Banana%%%%VAR%=%2%Apple%%%%VAR%=%3%Grape%%

Is also valid. It will only return 1 answer, whichever one is true first.

But no, you can't remove text that way.

Dice Roll Link Script Not Working

6 years ago
You don't use IF THEN with on page scripting or need the actual $PAGETEXT, just put the variable and text down like in Killa's example and it works the same way. It won't appear at all if the variable doesn't match and it's easy to just throw down several variations of anything anywhere on the page.

I use it any time I want variations in a character's dialogue or other minor choice responses that don't change the overall plot enough to need a completely different page. I almost never bother with $PAGETEXT, on page scripting is so much more flexible.

Dice Roll Link Script Not Working

6 years ago

Yeah, I just found that out after a lot of confusing trial and error! That's exactly what I'd like to use mine for: I want lots of very subtle changes to text depending on what's happened. However, I'm still encountering a problem. I've got two Variables, let's say %ONE and %TWO, which correspond to two different events happening. I wanted to set up On Page scripting on a page which both can lead to, which I've basically scripted as:  %%ONE%=%1%(text)%%%%TWO%=%1%(other text)%%

Then, on the page script where the event for %ONE occurs, I set the page script: %ONE:= 1 (where the %ONE has a minimum value of 0 and starts on zero) and the same for %TWO where it occurs. When I tested it, the text for %ONE never came up even when I went to the event, and only the text for %TWO came up when I didn't go to that event. Do either of you have any idea why this is happening? I've swapped the coding to change the values when the links are pressed instead of page script, checked I've got nothing in my global page or global script about the variables, and loads of other things. I'm baffled!

Thanks!

Dice Roll Link Script Not Working

6 years ago
"You can also chain these statements, assuming you're checking the same variable."

"assuming you're checking the same variable."

That's why. You're trying to check two different variables.

Dice Roll Link Script Not Working

6 years ago

Sorry! Okay, I'll try that out. 

Edit: Sweet lord it works! I tried separating them with a new paragraph, but I guess the computer reads it without lines so I had to separate them out with text in between. Is that the only way you can get two different variables to be checked in On Page scripting? Either way- thank you! 

Dice Roll Link Script Not Working

6 years ago
Technically you only need a space separating them, so:

%%ONE%=%1%(text)%% %%TWO%=%1%(other text)%%

Would work (notice the space between the two checks). Thing is, that space is shown on the page, so it looks a bit awkward in practice.

You can also make as many checks in as many different places on the page as you want, as long as they follow the format/rules we've mentioned.

Dice Roll Link Script Not Working

6 years ago

Ah okay, I guess as long as you have a sentence afterwards in normal text, you can just omit the space between On Page script and normal text, and it'll appear as the normal space between the end of one sentence and the start of another then. And if you don't have a sentence after, then I guess it doesn't matter anyway. This will be really helpful to my story!

Dice Roll Link Script Not Working

6 years ago
Just fyi, if you need someone to look your story over for any weird formatting or spacing issues you can co-author me, I'm guessing your reader may make that a little difficult.