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.

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