Login
Remember
IF Answers
Ask a Question

# How to set up a condition involving the presence of a character.

0 votes
53 views
asked Jun 25 in Authoring by Rohain

I'm trying to make it so that if the player passes through a metal detector while carrying a metal thing it goes off and they get arrested, but only if an authority is nearby. Right now I have:

    To detect the player:
        say "You pass through a metal detector.";
        if the player is carrying a metal thing:
            say "The metal detector blares annoyingly.";
            if in the presence of an authority:
                say "The guard grabs you and ends the story";
                end the story.;
            otherwise:
                say "Nobody is around to do anything about it though";
        Otherwise:
            say "You pass through it unmolested.";

And

    A person can be an authority.  A person is usually not an authority.

And

    In the Embassy Front Lawn is a man called a guard.  The indefinite article of Guard is "a".  A guard is an authority.

And finally:

    Instead of going south from the Embassy Front Lawn:
        say "You'll have to go through a security checkpoint.  It seems to have a metal detector, keep going?";
        if the player consents, detect the player.

It all works without the presence of the authority bit, but I can't inform to recognize that I only want the last bit of code to fire if there's an authority around.

- programming
- inform7

## 1 Answer

+1 vote
answered Jun 26 by Juhana (246 points)

You can either use

    if an authority is in the location:

or, more semantically correct and handles corner cases better (if the guard is in a booth or watching from another room):

    if an authority can see the player:

## Related questions

- How do I set up an "If" for a container to have multiple objects?
- Copying the location of a thing to a variable when it's in something other than a room.
- What's the best way to ask if any of a kind has a certain value for a property?
- How do I move an item I have more of in the world (since it's a kind of thing)?
- calculating the value of a variable

...