intfiction.org

The Interactive Fiction Community Forum
It is currently Sun Dec 09, 2018 3:39 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Jun 07, 2011 10:25 pm 
Offline

Joined: Tue Jun 07, 2011 10:06 pm
Posts: 35
Firstly off, please take pity on me. - I am very new to Inform7 (I just started my story last week) I have been cruising along, with a few tiny bumps in the road... but this recent one just baffles me!

I want to create a door which when examined opens an interface to give the password. The password being text that the user enters. (let's say "giggity") I have tried a few different approaches. I have been at this for 2 days now. Can anyone please help me out?
Here is my most recent try (which includes "Questions" by Micheal Callaghan, but I have obviously butchered it - as it throws out errors-galore):

Code:
[size=85]A text question rule:
   if the current question is "Can you picture the password?":
      if text understood is giggity:
         say, "**BUZZ**  You have unlocked the security door.";
         now the security terminal is unlocked;
         exit;
      otherwise:
         exit;
   otherwise:
      exit.

A yes/no question rule (this is the confirm answers rule):
   if the current question is "Would you like to try again? (Yes or No)":
      if the decision understood is yes:
         examine security terminal;
      otherwise:
         say "Goodbye.";
         exit;
   otherwise:
      exit.

Instead of inspecting security terminal:
   now the current question is "Can you picture the password?";
      now current prompt is "Please enter the password now. >";
      now punctuation removal is true;
      ask a closed question, in text mode;
   now the current question is "Would you like to try again? (Yes or No)";
   ask a closed question, in yes/no mode.[/size]

I did consider making the security door the door and security terminal a person, who can ask for the password using the [topic] table. I do not know if a dialog can trigger an action though(like 'now the security door is unlocked.'). Plus, I haven't played around with adding characters yet and don't really know what I'm doing at all there.


Last edited by anamri on Wed Jun 08, 2011 9:36 am, edited 3 times in total.

Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Jun 07, 2011 10:28 pm 
Offline
User avatar

Joined: Fri May 27, 2011 10:37 pm
Posts: 289
Props on the Family Guy reference, if that's what it was. My favorite show of all time.

Otherwise, I can't help you. Sorry.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Tue Jun 07, 2011 10:33 pm 
Offline

Joined: Tue Jun 07, 2011 10:06 pm
Posts: 35
Yeah, I was watching it earlier today and it was the first thing that popped into my head. ;)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 3:26 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 1102
Location: Gothenburg, Sweden
Here's a way:
Code:
The description of the security terminal is "Can you picture the password?"
After examining the security terminal:
   now the command prompt is "Please enter the password now. >";
   continue the action.
   
After reading a command when the command prompt is "Please enter the password now. >":
   increment the turn count;
   if the player's command matches "giggity":
      now the security door is unlocked;
      say "**BUZZ**  You have unlocked the security door.";
      now the command prompt is ">";
   otherwise:
      say "The security door remains closed.";
      now the command prompt is "Would you like to try again? (Yes or No) >";
   reject the player's command.   
   
After reading a command when the command prompt is "Would you like to try again? (Yes or No) >":
   if the player's command matches "yes" or the player's command matches "y":
      now the command prompt is "Please enter the password now. >";
      say line break;
      say run paragraph on;
      reject the player's command;
   if the player's command matches "no" or the player's command matches "n":
      now the command prompt is ">";
      say line break;
      say run paragraph on;
      reject the player's command;
   otherwise:
      say line break;
      say run paragraph on;
      reject the player's command.

_________________
Man ska inte tro allt man tänker.


Last edited by Felix Larsson on Fri May 18, 2012 4:28 pm, edited 1 time in total.

Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 8:54 am 
Offline

Joined: Tue Jun 07, 2011 10:06 pm
Posts: 35
Thank you SO much for your time and for trying to help!
That looks similar to my first try, but i have never used "run paragraph on" before. What does that do?

Also it's still giving me errors (I just copied and pasted, so that I wouldn't mess up your code):
Code:
Problem. The phrase or rule definition 'After reading a command when the command prompt is "Please enter the password now. >"'   is written using the 'colon and indentation' syntax for its 'if's, 'repeat's and 'while's, where blocks of phrases grouped together are indented one tab step inward from the 'if ...:' or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can't determine the structure. The first phrase going awry in the definition seems to be 'if the player's command matches "Keep" or the player's command matches "keep"'  , in case that helps. 

 This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.

It is giving me the same error for the first line in the next set also 'After reading a command when the command prompt is "Would you like to try again? (Yes or No) >":'
Perhaps there is some extension that you usually include that makes this work? If so, which one?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 9:30 am 
Offline

Joined: Thu May 20, 2010 9:33 pm
Posts: 679
Ah, you're being caught by the forum trick. The problem with copying and pasting from the forum is that if you copy from a post, the tabs have all been converted to spaces, and Inform really requires them to be tabs. One way to quickly work around that is to make as if to reply to the post containing the code (so, hit the "quote" button), then copy the code from within the reply-to text box, where the tabs will be magically restored to how the original poster typed them in. Of course, if the original poster typed them in as spaces, you'll still need to convert them to tabs by hand.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 9:31 am 
Offline

Joined: Tue Jun 07, 2011 10:06 pm
Posts: 35
Ok, I figured it out - my copy and paste job reads your code as having 3 spaces instead of a tab. I replaced all of the spacing with tabs and it worked PERFECTLY!!

THANK YOU Felix!! :D

(thank you Trove - you were replying just as i was! That certainly beats the way I did it! I will keep that in mind for the future.)


Last edited by anamri on Wed Jun 08, 2011 9:35 am, edited 1 time in total.

Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 9:34 am 
Offline

Joined: Tue Dec 25, 2007 10:06 am
Posts: 1541
This happens so often that maybe it would be a good idea to make a post with general instructions and make it sticky?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 10:21 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 1102
Location: Gothenburg, Sweden
anamri wrote:
I have never used "run paragraph on" before. What does that do?


You need to print a line break (or paragraph break) after the player has answered the question or there will be no blank line between the line with the answer and the new command prompt that follows the answer.
However, I found when testing the code, that (for some I6 reason, I think) the game would then print TWO blank lines between the lines rather than one.
This happens every now and then in Inform 7, and "run paragraph on" prevents it. It stops the next paragraph from beginning on a new line, and runs it immediately on as a single paragraph with the preceeding one (or something).

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Jun 08, 2011 12:10 pm 
Offline

Joined: Tue Jun 07, 2011 10:06 pm
Posts: 35
Thank you again Felix, you have been very helpful!


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 23 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