intfiction.org

The Interactive Fiction Community Forum
It is currently Mon Dec 17, 2018 3:46 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Mar 11, 2018 7:07 pm 
Offline

Joined: Sun Mar 11, 2018 6:46 pm
Posts: 4
Hi everyone,
I'm a very new Inform 7 user and to be honest the syntax is very confusing to me so this is probably simple to do but I can't figure it out.

I need to have a door that starts closed and un-openable. Then, the player presses a button in the room which opens the door. The door then remains open for the rest of the game.

I don't even know enough to figure out if I have to define for Inform what the verb "press" means (I know "push" is already used for moving objects around the room).
This is for a college project, and earlier in the year we worked with the Twine and Quest engines and I had no trouble understanding how to create fairly complex interactions. I don't know why Inform is so confusing for me.
Any help would be greatly appreciated!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Mar 11, 2018 7:19 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5448
Location: Burlington, VT
onyxbird wrote:
I don't even know enough to figure out if I have to define for Inform what the verb "press" means (I know "push" is already used for moving objects around the room).


Actually the pushing action is defined as what you want. (Moving objects around is a different action, called "pushing it to.") So you can do this:

Code:
Lab is a room. Foyer is a room.

The blue door is a door. It is north of Lab and south of Foyer. It is closed and unopenable.

The blue button is in Lab. It is fixed in place.

Instead of pushing the blue button when the blue door is closed:
   say "The blue door slides open.";
   now the blue door is open.


If you want to know which actions are built-in and how to refer to them, the Index is very helpful, particularly the "Actions" tab. This lists actions various ways--grouped by various characteristics, alphabetic by the name of the action, and alphabetic by the commands used to invoke the action (also two other ways you don't want to worry about now).

The difference between the name of the action and the name of the command is particularly important here. If you go to the "Commands" listing and look at "push," you will see this:

Quote:
"push [something]" - Pushing
"push [something] [direction]" - Pushing it to
"push [something] to [direction]" - Pushing it to


This indicates that there are two different actions that can be invoked by a command starting PUSH. If you type PUSH BUTTON that invokes the pushing action, which we just used. If you type PUSH CART WEST or PUSH CART TO WEST that invokes the pushing it to action, which gets referred to in the source code as "pushing the car to the west."

And if you click on the magnifying glass next to the action, you get a more detailed description, which can be helpful. In particular, it will give you the commands you can use to invoke the action. For pushing you get:

Quote:
"push/move/shift/clear/press [something]"


Which means that PRESS BUTTON will also work. (As well as weird things like SHIFT BUTTON and CLEAR BUTTON. I think this is because all those words are defined as global synonyms for "push," in case the player wants to say something like SHIFT CART WEST. It should be harmless to leave them in for the pushing action.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Mon Mar 12, 2018 12:58 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 384
matt w wrote:
(As well as weird things like SHIFT BUTTON and CLEAR BUTTON. I think this is because all those words are defined as global synonyms for "push," in case the player wants to say something like SHIFT CART WEST. It should be harmless to leave them in for the pushing action.)


That is correct. From the Standard Rules:
Code:
Understand "push [something]" as pushing.
Understand "push [something] [direction]" or "push [something] to [direction]" as pushing it to.
Understand the commands "move", "shift", "clear" and "press" as "push".


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Mar 14, 2018 2:33 pm 
Offline

Joined: Sun Mar 11, 2018 6:46 pm
Posts: 4
Thank you so much! This really helped.

On a related note, how would I make it so that a door can only be opened if two separate switches are switched on? Normally I would use an if statement checking whether the switches are both on, but I'm not sure how to phrase that for Inform. I only got as far as:

Code:
Antechamber is a room. Foyer is a room. Metal Door is a door. It is closed and unopenable. It is east of Antechamber and west of Foyer.

A Blue switch and a Green switch are in the Antechamber.

Instead of opening the metal door:
   if the blue switch is off:
      say "The door cannot be opened."



Apparently "if the blue switch is off" doesn't compile, and the documentation isn't helping me figure out what's wrong with it. Are switches not already defined as having the states "on" and "off"? How would I define that for Inform? It seems I'm not understanding how Inform thinks about objects and their properties.

Obviously I also need a way to simultaneously check the state of two separate switches and return a result only if both are on. How would I do that?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Mar 14, 2018 3:38 pm 
Offline

Joined: Fri Oct 18, 2013 10:13 am
Posts: 2669
Location: The Midwest
The states are called "switched on" and "switched off", to avoid confusion with "on the table" and similar phrases.

Code:
Instead of opening the metal door when the blue switch is switched off or the red switch is switched off:

_________________
Daniel Stelzer


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