[I7] Creating new verbs

I’m ashamed to admit that I’m just not understanding how to create new verbs.

I’d like my players to be able to pick a lock and play a message. For playing the message, I did

Understand "play message on answering machine" or "play message on machine" or "play message" or "listen to message on answering machine" or "listen to message on machine" or "listen to message" or "check message" or "check message on machine" as listening.

Instead of listening:
	if location is not Office:
		say "You don't hear anything."

There’s more code that follows about what the player does hear and under what conditions.

I don’t expect to put the player in another situation where they need to listen, and this listening hack seems to be working, but it feels hacky in the bad way. And I can’t think of a way to set up picking the lock without re-purposing Open or something, and that’s just a bad idea all around.

Is there anyone who has time to explain creating new verbs, bearing in mind that I’ve read the built-in documentation on Relations and worked through Sand-dancer and I’m still just not getting it? “Picking” would be a good example to work through, since I need to use it anyway and it would probably be a good foundation for when I inevitably need to create other verbs.

This is an “explain it to me like I’m 5” situation if ever there was one. Thanks for your help - it’s always appreciated.

2 Likes

Did you read Ch. 12 “Advanced Actions” – especially 12.7 “New Actions?” That’s where you want to look. :slightly_smiling_face: But in the meantime, I think it would best to work on the listening action first since it only needs one noun at most. The unlocking action, i.e. “unlocking it with” (see the Actions Tab in the Index) requires two nouns (unlock something with something) and is therefore more complicated.

For a hypothetical five-year-old, we should start with the former rather than the latter…

2 Likes

Looking at your post it looks like you are attempting to create a new action, I dont see exactly where you are creating verbs and using them (perhaps I overlooked it). I created a small example of picking a lock and then playing a message on a micro-recorder that was locked in the box. Playing is an action in the example and it is used in conjunction with the micro-recorder.

Indoors is a room.  There is a hairpin in Indoors.  
There is a screwdriver in Indoors.
The metal box is a locked container.  The metal box is in Indoors. 
The metal box is locked.  There is a micro-recorder in the metal box.

Playing is an action applying to one thing.
Understand "play [something]" as playing.

Instead of playing the micro-recorder:
	say "Get out, get out now... this message will self destruct in 10 seconds!!";
	
Instead of unlocking the metal box with anything (called pick):
	If pick is the hairpin:
		say "Your struggle but eventually pick the lock.";
		Now the metal box is unlocked;
	Otherwise:
		say "You try to pick the lock with the [printed name of pick] but it is no use.".

Regarding creating verbs (not new actions), I learned a little more about verbs myself when I saw some example code that defined left, right, atop, and under as verbs that could be used with objects in Inform7. The concept of directions just seemed to make it easier for me to understand. Once the right, left, atop, under relations are created you can use them to say different things like:

say "[item_i] is [if item_i is left of item_j] left [otherwise if item_i is right of item_j] right [otherwise] neither right nor left [end if] of [item_j].[line break]";

Here is the simple verb example I was talking about below. This code came from a larger thread talking about positioning objects in 2D coordinates in Inform7. I will link it below.


[Define a point.]

A point is a kind of thing.

[Define relations and verbs to use with points]

Leftness relates various things to various things.
The verb to be left of means the leftness relation.
The verb to be right of means the reversed leftness relation.

Atopness relates various things to various things.
The verb to be atop means the atopness relation.
The verb to be under means the reversed atopness relation.

[Define some points in the demo room]

Demo is a room.

point_a, point_b, point_c, and point_d are points in Demo.

[Orient the points]

point_a is right of point_b.
point_b is right of point_c.
point_d is atop point_a.
point_e is atop point_d.

[examine points]

Instead of examining a point (called temp):
	let item_i be a point;
	let item_i be temp;
	let J be the list of points;
	repeat with item_j running through J:
		say "[item_i] is [if item_i is left of item_j] left [otherwise if item_i is right of item_j] right [otherwise] neither right nor left [end if] of [item_j].[line break]";
		say "[item_i] is [if item_i is atop item_j] atop [otherwise if item_i is under item_j] under [otherwise] neither atop nor under [end if] of [item_j].[line break]";
	say "[line break]";
2 Likes

Try this and see if you follow it:

Office is room.
The answering machine is in the Office. It is fixed in place.
The Back is north from the Office.

[Note that "the ambient sound rule" supplies the location as the noun if not specified. Unfortunately, this isn't in the actions Index, but can be discovered by tuning rules tracing on. Run the test script to see.]

Check listening (this is the only listen to the answering machine rule):
	if the noun is not the answering machine and the noun is not the Office:
		say "You don't hear anything." instead.
			
First report listening (this is the answering machine message rule):
	if the noun is the answering machine or the noun is the Office:
		say "You hear a message about your car's warranty expiring, which is funny since your car is a [apostrophe]94 Tercel." instead.
		
test me with "listen / listen to machine / listen to me / n / listen / listen to machine / s / rules / listen".

edited to add this:

Understand "play [answering machine]" as listening to when the location is the Office.
Understand "tape" or "message" as the answering machine.

test play with "play machine / play message / play tape / play / listen to message / listen to tape".
1 Like

Some suggestions–

Does your answering machine have a ‘play’ button?? Then all you need from the player is to have the player ‘push’ the ‘play’ button–

...
A play button is a part of the answering machine.  The description is "It's red and says 'play'."
Instead of pushing, touching, switching on, or rubbing the play button:
    say "Instantly, the answering machine says, 'You have...one...messages.  Message number one:  [insert message here]…"
Instead of switching on the answering machine:
     try pushing the play button.
….

I would also suggest creating an all-purpose action called ‘Using’, and have an Understand statement including various commands that one would attach to certain odd objects–

Using is an action applying to one touchable thing and requiring light.  Understand "use [something]", "check [something]" or "play [something]" as using.
Check using something:
     if the noun is not the answering machine or the noun is not [any other odd object(s) that you have implemented with 'using']:
          instead say "You will need to specify how you want to use that."
…
Check using the answering machine:
     instead try pushing the play button.[to route the action to the correct outcome]

‘touchable’ means anything that the player can touch, either scenery or takeable items, as opposed to ‘walls’ (which are directions), and other abstract items.

For the lockpicking you can create another action, ‘Using it on’ for two nouns –

Using it on is an action applying to one carried thing and one visible thing, and requiring light.  Understand "use [something carried] on [something]" as using it on.  Understand "pick [something] with [something carried]" as using it on (with nouns reversed).
…
Check using something on something:
    if the second noun is the huge padlock:[have an 'if' statement for any 'second noun' that can produce results when you 'use' something on it]
         if the noun is not the needle or the noun is not the [and so on for each noun that can be used to pick the lock]:
               instead say "Well, [the noun] is just not fit for picking this lock.";
    otherwise:[to cover everything that does not produce a result when something is 'used' on it]
         instead say "You'll need to specify how to use that."
…
Check using the needle on the huge padlock:
    if the huge padlock is unlocked:
         instead say "Whoops, it's already unlocked!"
After using the needle on the huge padlock:
    say "With careful concentration, you fumble around inside the lock, the needle gripped tightly and expertly in your fingers.  Then 'Pop!' the lock opens!";
    now the huge padlock is unlocked.

‘Something carried’ implies that the parser will automatically have the player first try to pick the item up, and then try the action. A ‘visible thing’ is anything, abstract or not, scenery or takeable, that the player can see. The (with nouns reversed) must be added for cases where the player might express the second noun (such as the huge padlock) before the thing being used–such as ‘pick the huge padlock with the needle’, rather than ‘use the needle on the huge padlock’.

The thing is to avoid having to create actions whenever possible. Always try to think of how your action can be made into a synonym for an action that is already built into inform. We might have made ‘pick [something] with [something carried]’ synonymous with ‘unlocking it with’, but then we would have to make the lockpick item into a matching key, which would then be capable of locking the lockable item back, and ideally you don’t want the carried item to be an actual key; also, you would want other items to be usable to pick the lock with (presuming that the player has that skill), and Inform7 does not allow multiple matching keys for one item, without writing special rules to compensate. It’s just better to have another action in my opinion.

I hope that this helps!

2 Likes

Another suggestion, applying to your answering machine–

You can make ‘messages’ a synonym for the answering machine–

Understand "messages" as the answering machine.

Then, having “check [something]” synonymous with “use [something]”—

Instead of using the answering machine:
    try pushing the play button.

Just a suggestion.

Yet another suggestion and then I will shut up.

‘Listening to’ is built-in, but it is such a wonky action (for reasons I won’t go into here) that I do away with it altogether and instead create two new actions to replace it, one for just listening to things, and the other for just listening–

Hearing is an action applying to one visible thing.  Understand "listen to [something]" as hearing.  
Check hearing:
    instead say "Why, that sounds just like a [noun]."

And for any thing that you want there to actually be a unique result for this action, you would write an Instead rule, which will bypass the check rule above–

Instead of hearing the woodpecker:
    say "'Tock!  Tock!  Tock, tock!' he says."

For just listening–

Radaring is an action applying to nothing.  Understand "listen" as radaring.
Check radaring:
    instead say "You hear only the ringing in your ears."

Then you can write an Instead rule for any location that might have a unique result–

Instead of radaring in Beach Front:
    say "You hear the waves, and a couple of amateur surfers, crashing against the nearby rocks."

For your answering machine, you can say–

Instead of hearing the answering machine:
    try pushing the play button.

Just another suggestion.

1 Like

Wow, this is all a lot to take in! Thank you, everyone. I’ll take another crack at things in the morning and let you know how it goes.

One thing I forgot to add, if you want to ‘re-create’ the action ‘listening to’–you’ll have to add a couple of line to tell the parser to re-direct to the new actions–

Understand the command "listen" as something new.  Understand the command "hear" as something new.

These lines must be typed in this way. These are both of the commands that lead to ‘listening to’. Also, you’ll need to say –

Understand "hear [something]" as hearing.  Understand "hear" as radaring.

I forgot to add them to my Understand phrases above.

Just some suggestions.

FYI, “listen to [something]” is also separate grammar linked to listening, so if you want to completely get rid of listening then you’ll have to override that too.

An easier way to completely disable a built-in action (and any commands it might have been linked to) is to use:

Understand nothing as listening to.

Then you can redefine the commands as in your second snippet (no need for the first), without fear of some dangling commands you forgot about. :slight_smile:


Having said all that, I’m not sure why you said listening is a wonky action. It works the same way as smelling – if the player types listen with no noun then they will implicitly listen to the location. This means you can write Instead rules for general listening (Instead of listening to the Office) or listening to a specific object (Instead of listening to the answering machine).

It works quite well, with no need to define separate actions for each case. Just remember that it’s always listening to and never listening in.

2 Likes

Well, it could be because at the time when I started substituting those other two actions, I was confused about whether the action should be referred to as ‘listening’ or ‘listening to’. In a list of allowed actions ('Instead of doing anything other than…) for an object, you have to list it as ‘listening’, (whereas in the Index, it’s listed as ‘listening to’).
I think I have been doing it this way because at the time I was working on a game where an interaction required a lot of juggling with ‘the player’s command’ and ‘the current action’, and using those substitutes made it easier and I’ve been doing it that way since. Just sharing what works for me.

Thank you for your tips.