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?

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.

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