Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Relationship Scripting

3 years ago

first thing's first, i'm still trying to write storygames. and failing. i'll usually just delete my projects. that's beside the point, thing is, i'm trying to invest some time into the ambitious art of making a storygame that incorporates relationships. not romance, but general relationships. i understand how to use variables in a basic sense, but after scouring the forums and the help pages on scripting, i still haven't found what i'm looking for. last ditch effort for me was to come here and express my need for information.

i already know how to script the simple 'if variable goes over number, go here' but that's way too simple and not nearly as flexible as i need. if there's a way, i'd like to learn and understand how to script variables in a way that a certain choice is affected by a variable. like, 'if variable is over number, go here' and 'if variable is under number, go here' alongside a 'if variable is this number exactly, go here'. i know simple workarounds for the first two options that don't require scripting, but with this third option appearing... it's time i looked deeper into the scripting of variables. essentially, i'd like the variables to work with the options, and not the variable page, since the story's relationship level determines the fate of characters and the direction of story.

if there's a link to a page that covers this that i missed or didn't read too in-depth on to get my answer, i don't mind someone just linking that if you don't feel any desire to give me a long-winded explanation. thanks for your time.

Relationship Scripting

3 years ago

So, you want a script to be evaluated when a link is clicked?

Next to the link is a blue := button called 'edit link script'. There you can put the logic for what you want:

IF %VARIABLE < 2 THEN $DEST := @P8
IF %VARIABLE = 2 THEN $DEST := @P9
IF %VARIABLE > 2 THEN $DEST := @P10

(Swap variable name, numbers, and destination pages to whatever you want)

You can also use IF [stuff] THEN IF [stuff] etc to check multiple things.


Check 'editor features' under 'story properties' to see if scripting is enabled (I believe it starts off by default, and the script page for a link might require it to be turned on).


Page scripts along with global link & page scripts also exist.

I'm not an expert, but I believe the difference between these is when the script runs.

Global Link Script: runs when any link is clicked.
Global Page Script: runs when any page is loaded.

Link Script: runs when that specific link is clicked.
Page Script: runs when that specific page is loaded.


I think that covers what you're looking.


Oh, also, there's on page scripting, where you put the script on the page. It is used for checking variables and then displaying text if the condition is true. It looks like this:

%%VARIABLE%=%1%text shown if VARIABLE is 1%%

You can also combine multiple ones of the same variable. Such as:

%%VARIABLE%=%1%first variation%%%%VARIABLE%=%2%second variation%%

You might've already found this in the articles, but because it is useful I figured I'd mention it (just in case).

Relationship Scripting

3 years ago

thanks, mate. you've been a phenomenal help. i probably could have figured it out had i just spent more time digging through the 'how to's' but a human response is far more appreciated.