Login
Remember
IF Answers
Ask a Question

# 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.

- quest
- gamebook
- if-script

## 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.

## Related questions

- Quest Gamebook: Return to a previous page with multiple links, and make link already chosen inactive
- In a Gamebook, how do I fix that the text processor is not working properly on my version of Quest (I think)?
- Quest Gamebook: Can I allow players to choose their own name?
- Gamebook: How to include a player's attributes/stats?
- Quest: if's, exits, blocking and attributes

...