Quest Gamebook: How to use AND OR and NOT inside an "if" command?

0 votes
129 views
asked Jul 21 in Authoring by Werew

I am using a system where flags are set on as certain conversations are had, and then these flags are used later to make various characters dynamically aware of what has happened before, or to make some links inactive if certain conditions are or are not met. I was previously under the impression that I could use AND, OR, and NOT inside an 'if' command with impunity, but lately something hasn't been working right with an OR command.

So I have a room in which there are three people and you have options to go talk to each one and then possibly leave with them, depending on conditions. So when you talk to person 1, it sets a personone flag on. Person three is really picky about whether you've talked to the others, so I want him to react as follows:

If you go to him after talking to ONE of the others, he will talk to you, but only grudginly:

{if personone or persontwo:"Okay fine, I guess."}

If you go to him after talking to the others, he's more receptive:

{if personone and persontwo:"Yeah, you can come with me."}

If you go to him first, he outright rejects your attempts to talk:

{if not personone and not persontwo:"Go away!"}

But the problem I'm having is that it keeps going to the reject option when I have talked to ONE of the others. I thought that I could use the OR command to tell it to activate that option when only one of the things is true but not the other, but it detects that one of the flags isn't there and picks only the reject option. Am I going to need to nest IF commands:

{if personone:{if not persontwo:"Okay fine, I guess."}}{if persontwo:{if not personone:"Okay fine, I guess."}}

Or is there an easier way to do this?

Thanks for any help you can offer. I'm not having luck finding it in the documentation.

1 Answer

+1 vote
answered Jul 23 by jaynabonne (141 points)

The problem is that the text processor's "if" is very simplistic, as you have discovered. You can do things like check flags, compare values with equalities and inequalities, etc.

Instead of flags, you could have a count of how many people have been talked to. Then you could have

{if talkedto=0:"Go away!"}

{if talkedto=1:"Okay fine, I guess."}

{if talkedto=2:"Yeah, you can come with me."}

Just start player.talkedto out at 0 and increment it when you talk to either person one or person two.

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...