Creating new action/ unlocking issue


#1

I am extremely new to the IF world but I am using Inform 7 for one of my classes this semester. What I want to do is point a wand at a door in order to unlock it. I’ve tried several different ways and Inform 7 does generate it each time without any errors…

Pointing is an action applying to one carried thing and one visible thing.

Understand “point [carried thing] at [something]” as pointing.

pointing wand at embroidered door unlocks embroidered door.

instead of pointing wand at embroidered door: now the embroidered door is unlocked; say “The lock clicks.”

…but when I try “point wand at embroidered door” in the game nothing happens at all. Does anyone know what I am missing?


(Hanon Ondricek) #2

One handy tool–run your game in the IDE and then type ACTIONS. As you continue to play, the game will list what code-level actions it’s trying and what is preventing them from succeeding.

That’s the syntax for defining a key that unlocks a door, not an action.
You need to define rules to carry out actions.

Test room is a room.

an Embroidered door is a locked door. It is north of test room and south of victory room.
The player carries a wand.
pointing it at is an action applying to two things.

Understand "point [something preferably held] at [something]" as pointing it at.

Check pointing the wand at something (this is the wand doesn't unlock everything rule):
	if the second noun is not the embroidered door:
		say "Nothing seems to happen." instead.

After pointing the wand at the embroidered door:
	if the embroidered door is locked:
		now the embroidered door is unlocked;
		say "There is a puff of smoke, and you hear a click from the embroidered door.";
	otherwise:
		say "There is a puff of smoke, but the door seems to be unlocked already."

Test room
You can see an Embroidered door here.

actions
Actions listing on.

open door
[opening the Embroidered door]
It seems to be locked.
[opening the Embroidered door - failed the can’t open what’s locked rule]

point wand at me
[pointing the wand at yourself]
Nothing seems to happen.
[pointing the wand at yourself - failed the wand doesn’t unlock everything rule]

point wand at door
[pointing the wand at the Embroidered door]
There is a puff of smoke, and you hear a click from the embroidered door.
[pointing the wand at the Embroidered door - succeeded]

point wand at door
[pointing the wand at the Embroidered door]
There is a puff of smoke, but the door seems to be unlocked already.
[pointing the wand at the Embroidered door - succeeded]

open door
[opening the Embroidered door]
You open the Embroidered door.
[opening the Embroidered door - succeeded]


#3

Oh I did not think to use a check rule, thank you! But I’m still having problems with it generating.

It doesn’t generate properly for a few reasons:

Problem. You wrote ‘otherwise’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).

It also had some issues with “check pointing the wand at something” though that error message did not appear this time.

I’ve tried to change the other wise but then an error message appears for something else.


(matt w) #4

This looks like the message that you get when the Inform compiler thinks that “otherwise” is the beginning of the code block. Have you made sure that the line before “otherwise” doesn’t end with a period, and that there isn’t an extra blank line before it? Either periods or blank lines get treated as the end of a code block.

As far as “check pointing the wand at something,” have you defined your action as “pointing it at”? (In the line “Pointing it at is an action applying to…”) The “it” is important here because it lets Inform know where to expect the first noun–so it knows that the “at” will come between the nouns when you say “check pointing the wand AT something.”


#5

I initially tried:

after pointing the wand at the embroidered door:
if the embroidered door is locked:
now the embroidered door is unlocked;
say “The lock clicks.”
otherwise:

But when I do it that way, Inform reads " ‘The lock clicks.’ otherwise" as connected. So I had added the period after my quoted text. Which also did not work.
I did modify “pointing it at”. I also changed the Understand line to “understand x as pointing it at” , is that right?


(Hanon Ondricek) #6

You need a semicolon if the rule is continuing:

After pointing the wand at the embroidered door:
	if the embroidered door is locked:
		now the embroidered door is unlocked;
		say "The lock clicks.";
   	otherwise:
		[...]

#7

That did it! Everything works perfectly now! Thank you so much you guys, this was extraordinarily helpful :smile: