Login
Remember
IF Answers
Ask a Question

# How to allow an action only if the item is picked up?

0 votes
112 views
asked Mar 29 in Authoring by anonymous
recategorized Mar 30 by Alex

Sorry for noob question. I have a radio, the radio has a battery compartment, which is a locked container, unlocked with a screwdriver.

1 - How do I understand unscrew as unlock, but only for the compartment, so things like "unscrew backpack" won't happen?

2 - How do I force the player to pick up the radio before unscrewing the compartment, but again not ending up with having to pick up other compartments?

- inform7

## 1 Answer

+1 vote
answered Mar 29 by Juhana (246 points)
edited Mar 29 by Juhana
Best answer

1 - You can redirect the turning action (which includes the command >UNSCREW) to unlocking with an instead rule:

    Instead of turning the battery compartment:
        say "(with the screwdriver)[command clarification break]";
        try unlocking the battery compartment with the screwdriver.

    Instead of turning the battery compartment when the player is not carrying the screwdriver:
        say "You don't have a suitable tool."

Note the second rule that takes care of the situation where the player doesn't have the screwdriver.

2 - You can again write a rule:

    Instead of unlocking the battery compartment with the screwdriver when the player is not carrying the radio:
        say "It would be easier to do that while holding the radio."

(This could also be a check rule, depending on what other rules there are for the unlocking action.)

On the other hand from game design perspective it's better to implicitly have the game take the radio instead of forcing the player to do it.

    Before unlocking the battery compartment with the screwdriver when the player is not carrying the radio:
        say "(first taking the radio)[command clarification break]";
        try taking the radio;
        if the player is not carrying the radio, stop the action.

The "if the player is not carrying the radio" makes sure that the game doesn't continue with unlocking the battery compartment if taking the radio failed for some reason.

## Related questions

- How to cause an event to occur on every turn, but only when the action succeeds?
- How do I move an item I have more of in the world (since it's a kind of thing)?
- The inform IDE is only so flexible for text editing. Do I have to use it?
- How to set up a condition involving the presence of a character.
- How do get an NPC's mood to worsen if I give it something it dislikes?

...