Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

How to add if/then statements?

7 days ago
Hey all, quick question about some game mechanics: Is it possible to have certain choices affect much later choices?

To explain, imagine that if a reader chooses choice A after a conversation with a character, they will earn that character's friendship. And if they choose choice B, they don't.

Then, much later in the story, the reader has to choose someone to ally with. I want to find a way where if the reader chose choice A earlier, they have that character open to them to choose as an ally for this choice. But if they chose choice B, that option is unavailable to them.

My limited coding experience tells me it should be a simple If/then statement but I have no clue how to add it to the game.

Thanks!

How to add if/then statements?

7 days ago
Yes.

If that's all you want to do, I think the easiest way to do that will be to set a variable when the reader selects choice A; then later in the story you can use link restrictions to limit the options available to the reader.

The short version: on the first link, use the % sign to modify a variable (after you have created one).

On the second link, use the button that is a red circle with the square in it to limit link options.

How to add if/then statements?

7 days ago
Another useful variant:

IF %BFFS = 1
$DEST := @P31

"If you toggled on the best friends forever variable with an earlier choice, then override the destination of this link with a new page number instead"

So instead of the page the link is pointing at, if the variable matches it shunts the player to the one where you're having pillow fights and braiding each other's hair instead.

Switching out the links altogether works just as well, but this is a little easier to set up imo.

How to add if/then statements?

7 days ago
Ha! I was thinking more along the lines of she lends you her assassins to help overthrow a tyrant king but sure, pillow fights will be the day after

In terms of mechanics however, I'm more concerned with making restricted choices, I think.

Imagine you separately meet three people and say the right thing to each so they are your ally. Then much later, you have to choose one. Since you've allied with all, all three are available to you. If you've only allied with two, and accidentally insulted the third's horse, then only two names are available. If you've insulted everyone's horse, you have no ally options.

Now how would you go about that, without making duplicate pages with different choices?

How to add if/then statements?

7 days ago
Thanks for the help Ogre11, I'm going to try this out! I'm a bit hazy on where/how to add % sign though.

How to add if/then statements?

7 days ago
You might need to go into Editor Options (on the Story Properties page) and set scripting to advanced.

You should be able to open up a link script box for the page then, the % in front of a variable name is how you reference it in a script and tell the editor to either check the value, or set the value.

You can do essentially the same thing in the mode with the plus and minus signs where you're typing values in the little boxes. It just is more finicky to set up IMO, and you need to go and create the variables in their tab before you can view them.

How to add if/then statements?

6 days ago
As mizal pointed out, you need to ensure options are set to advanced. That's on the storygame properties page, at the bottom, select change editor features and set both to advanced.

Then on the variables page, create three variables, something like BobFriend, PhilFriend, and LisaFriend.

Now, on the page where the reader decides to be their friend, at the bottom of the page where you see Link Text, to the left of the text that says, "I want to be Bob's Friend," there is a little +- sign button. Click on that and you will see a list of variables. You can change BobFriend to 1.

Finally, on the page where Bob's help is available, you can use the little Stop sign button next to the link text. When you click that, you can choose variable restrictions and choose BobFriend and 1, then the link will only appear if the BobFriend variable is 1.

Later, if the reader pisses Bob off, you can use the process above to set the variable back to zero.

Hope that helps!

How to add if/then statements?

5 days ago
Oh this is perfect, just what I needed

Thank you very much!

How to add if/then statements?

yesterday
Glad to help, hope it all worked out for you!