intfiction.org

The Interactive Fiction Community Forum
It is currently Tue Nov 20, 2018 9:49 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Sep 11, 2018 1:27 pm 
Offline

Joined: Tue Sep 11, 2018 1:21 pm
Posts: 4
I'm having some trouble with Inform 7. I want to make it so that a door is locked, as is only unlocked when the player says "please." I'm very new to the program and I'm having difficulty understanding how to achieve this. Here is my current code, which is really getting me nowhere:

Code:
The gate is east of the Gate_Forest and west of the West_Forest. The gate is a door. The gate is lockable and locked. "Beyond, you see a large wooden gate, hidden in the trees."

Please is an object.

Saying is an action applying to one thing. Understand "say [something]" as saying.

Check saying:
   if the noun is please:
      say "The door unlocks.";
      now the gate is unlocked;
   otherwise:
      say "Your voice echoes through the forest. No response."


Anyone have any ideas? Thanks in advance!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Sep 11, 2018 1:56 pm 
Offline
User avatar

Joined: Tue Nov 08, 2011 8:11 am
Posts: 2767
Location: US - Central
You kind of have the idea, but it might be better to make a more specific action. "Please" doesn't need to be an object.

Here's what I would do.

Code:
Pleading is an action applying to nothing. Understand "please" and "say please" and "say please to door" and "tell door please" as pleading.

Check pleading:
     if the player can touch the magic door and magic door is locked:
          now magic door is unlocked;
          say "The door appreciates you asking nicely, and you hear a click.";
     otherwise:     
          say "Your request goes unanswered." instead.

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


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Sep 11, 2018 2:09 pm 
Offline

Joined: Tue Sep 11, 2018 1:21 pm
Posts: 4
Yes, that's perfect! I guess I have to get used to being more specific. Thank you for your help!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Sep 11, 2018 2:33 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5806
I agree that "please" doesn't need to be an object in this case, but you should use the door object in the grammar. When you hard-wire the entire command like that, you're bypassing all of Inform's synonym mechanisms. Also "it" and so forth.

I'd set up the grammar like "say please to [something]", "tell [something] please", and so on.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Sep 16, 2018 12:58 pm 
Offline
User avatar

Joined: Tue Nov 08, 2011 8:11 am
Posts: 2767
Location: US - Central
Very true - In an extensive game where you're working a lot with doors, you certainly should wire it up correctly to get along with the world model. My suggestion was the "quick and dirty" solution (which I use to work around potential weird commands the player might try that will goof up the parser.)

_________________
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  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 8 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