intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Jan 19, 2019 7:07 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Picking a lock
PostPosted: Sun Jan 13, 2019 10:26 am 
Offline

Joined: Fri Oct 06, 2017 8:19 am
Posts: 31
In my game there is a locked toolbox. There is no key. You have to pick to lock on it with a nail.

How can I attach the action/verb 'pick' to the toolbox?

Thanks.


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Picking a lock
PostPosted: Sun Jan 13, 2019 11:28 am 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 312
Location: Michigan
You can make a "picking it with" action:

Code:
picking it with is an action applying to two things. understand "pick [something] with [something]" as picking it with.

The basement is a room. The description is "A basement with a dirt floor and a low ceiling."

The toolbox is an openable locked container in the basement.

The nail is in the basement.

Instead of picking the toolbox with the nail:
   say "After a bit of struggle the lock pops.";
   now the toolbox is unlocked.


Sample output:

Code:
basement
A basement with a dirt floor and a low ceiling.

You can see a toolbox (closed) and a nail here.

>pick toolbox
What do you want to pick the toolbox with?

>pick toolbox with nail
After a bit of struggle the lock pops.

>open toolbox
You open the toolbox.

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Picking a lock
PostPosted: Sun Jan 13, 2019 11:43 am 
Offline

Joined: Fri Oct 06, 2017 8:19 am
Posts: 31
Perfect, thank you!


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Picking a lock
PostPosted: Sun Jan 13, 2019 11:48 am 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 404
Alternatively you could fake it:
Code:
The Basement is a room.
The toolbox is a container in the Basement. It is closed, lockable and locked.

The player carries a hammer. The player carries a rusty nail.
The matching key of the toolbox is the rusty nail.

Understand "pick [something] with [something]" as unlocking it with.
Understand "lock" as the toolbox.

Report unlocking the toolbox with the rusty nail:
   say "After a bit of struggle the lock pops.";
   rule succeeds.

Check locking the toolbox with something:
   say "You fail to lock it." instead.

(It saves having to write generic rules for a new picking action---not that this would take much effort.)


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Picking a lock
PostPosted: Mon Jan 14, 2019 4:45 pm 
Offline

Joined: Tue Jan 26, 2016 9:35 am
Posts: 67
When defining a new verb to use on [someting] be aware that it would be nice to define a negative response for the player attempting to use the command on other things (oh, they will). So I usually do a before check (when using instead) and specify the concrete, "meant to be" actions as instead of - this will produce meaningful errors instead of a blank line:

Code:
"Lockpicking" by HtF

picking it with is an action applying to two things. understand "pick [something] with [something]" as picking it with.

The basement is a room. The description is "A basement with a dirt floor and a low ceiling."

The toolbox is an openable locked container in the basement.
The bucket is a thing in the basement.

The nail is in the basement.

Before picking something (called TheTarget) with something (called TheObject):
   if TheObject is not the nail:
      Say "Hm, we need something else to try lockpicking with."  instead;
   if TheTarget is not the toolbox:
      Say "There's no need to try to lockpick that." instead;
      
instead of picking the toolbox with the nail:
   say "After a bit of struggle the lock pops.";
   now the toolbox is unlocked.

test me with "get nail / pick bucket with nail / get bucket / pick toolbox with bucket / pick toolbox with nail"


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Picking a lock
PostPosted: Tue Jan 15, 2019 2:13 pm 
Offline
User avatar

Joined: Tue Nov 08, 2011 8:11 am
Posts: 2841
Location: US - Central
My only comment is to be aware of a subtle difference between BEFORE and CHECK:
Quote:
ยง7.3. Before rules
Despite what was said in the previous section, instead rules do not quite bypass all of the usual rules. Inform knows that certain actions require light: for instance,

examining the napkin; looking; looking under the dining table

and if it is dark then none of these actions will be allowed, and any instead rules about them will not even be reached. Similarly, Inform knows that most actions require physical access to their objects: so "taking the napkin" would be blocked if the napkin were, say, inside a closed glass bottle, whereas "examining the napkin" would not. So an instead rule can only take effect if the action has already passed these basic reasonability tests.

"Before" rules genuinely precede checking of any kind. They also differ from instead rules in that they do not automatically stop the action in its tracks. Rather, they are provided as an opportunity to ensure that something else is done first.

The easiest explanation is you'd use "Before picking the lock...instead" for a message like "You know you don't have the tools to pick the lock." and "Check picking the lock...instead" for "As much as you work the icepick in the lock, it won't open."

You may not want
Code:
Before picking something (called TheTarget) with something (called TheObject):
   if TheObject is not the nail:
      Say "Hm, we need something else to try lockpicking with."  instead;

to fire in a dark room.
Code:
Check picking something... ...instead

Will allow darkness and scope parsing first. This of course won't apply if you're not using darkness in the game, but it's good to be aware of when your refusal messages are specifically based on sight or touchability.

Before rules are mostly intended for messages like
Quote:
>THROW GRENADE
First pulling the pin...

because Before rules continue by default. Of course, they will work to block action, but it's a matter of preference.

_________________
http://hanonondricek.wixsite.com/pyramidif
https://pyramidif.itch.io/


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group