How do I write rules about an inanimate object performing an action?

I’ve added a “Sound” stage to the action-processing rules, which gets run if the action is within a certain distance of the player. In other words, I can write “sound of someone opening a door:” to alert the player to that action if they’re close but not in the same room.

So far so good.

Now, I also have some doors that close themselves after one turn. I want these doors closing to make a sound, but there’s not necessarily a person nearby to do it. My solution was to “try the hatch closing the hatch”, which Inform accepts without issue.

Still so far so good.

Except…“sound of a door closing a door” causes a compilation error. Inform doesn’t seem to like descriptions of things that are not people in the actor slot of an action specification.

How should I write rules with an action specification including an inanimate actor?

1 Like

P.S. I realize this will mean 3/3 of my parser games have mechanics revolving around knowing what actions NPCs are performing in distant rooms. Maybe that’s becoming my signature or something.

3 Likes

No doubt one of the smart folks will by be soon with the elegant solution, but I’d just create a new kind of person called a door-closer, give every door one of them, and have them be the ones actually doing the actions.

EDIT: this “solution” works even better if you forget to make them privately-named, I think.

1 Like

This seems to compile and run just fine:

"Sandbox" by Brian Rushton.

Toyroom is a room.

Playroom is north of toyroom.

The rock is a thing in toyroom.

Every turn:
	if the rock is in toyroom:
		try the rock going north;
	otherwise:
		try the rock going south;	
		
Report the rock going:
	say "The actor is [the actor].";


It identifies the rock as an actor, and ‘showme rock’ gives me this:

Footnote on 'showme rock'

image

>showme rock
rock - thing
location: in Toyroom
singular-named, improper-named; unlit, inedible, portable
list grouping key: none
printed name: "rock"
printed plural name: none
indefinite article: none
description: none
initial appearance: none

What does your ‘sound of’ code look like? Also, are you using Inform 7 or Inform 10?

3 Likes

is ““sound of someone opening a door” an actual value of kind sound name?

Hmm. I wonder if there was something else in my minimal example throwing it off.

Time to experiment more! I’m using 10, currently, in an attempt to be forward-looking.

1 Like

Great thought but no, I have no sounds or figures in this project.

I think the compiler just doesn’t like “sound” or “door”. This works.

sound-of-a-door is a thing.

when play begins:
try sound-of-a-door jumping.

before: if the actor is not a person, say "1"

Doing perverse things with Inform is my jam so here I demonstrated making the I6 compass object an actor.

4 Likes

Following up on this, it seems to be specifically using these in a rule preamble that’s forbidden. Because this doesn’t work.

The dimensional gate is a door. It is east of beta and west of delta.
When play begins: try the dimensional gate opening the dimensional gate.
Report a door opening a door: say "Foo."

The second line works, the third line doesn’t.

2 Likes

How about Report something that is a door opening a door:...?

2 Likes

That compiles!

1 Like

You can’t use the bare name of any kind, animate or otherwise, in the place of ‘an actor’ in an action specification- or even a bare ‘someone’ or ‘something’.

But, as Otis points out, you CAN use any other description of objects in the form for example of ‘something which is a door’ or ‘someone who is an animal’ or ‘a door which is open’ or even ‘an open door’

Or, perhaps more canonically, ‘an actor which is an open door…’

EDIT: Oops- a bare ‘someone’ or ‘something’ can be used in plce of ‘an actor’ in an action pattern- see post below

1 Like

Perhaps a little easier to read:

To decide which object is itself:
	decide on the person asked. [actor]

Report something opening itself:
	say "Foo." instead.

Report something closing itself:
	say "Bar." instead.
3 Likes

Huh! I never knew that; I don’t think I’ve ever tried writing rules like “instead of a man waiting” but I would always have expected it to be allowed.

“Someone” is allowed, but of course that’s a special case.

I wonder why it works this way? I would think that underlyingly “something that is a man” and “a man” would be the same sort of thing, since they’re interchangeable in other parts of an action description (“instead of attacking a man”).

1 Like

Oops, my mistake, I made some error in testing that led me to believe that a bare ‘someone’ and ‘something’ were also not permitted, when in fact the former is compiled to refer to any person who is not the player and the latter to any thing that is not the player.

I also notice something else weird though- ‘an actor’ in an action pattern usually is special-cased to refer to ANY object, including the player, but ‘an actor who…’ and ‘an actor which…’ specifically exclude the player, in addition to any other conditions applied after the ‘who…/which…’ So ‘an actor who is the player’ will never match, being compiled to if ( (actor~=player) && (act_requester==nothing) && (actor == player))

EDIT: consequently, as far as I can see, there is no way to include the player in any description of objects given to match with the actor for an action pattern except for the plain special-cased ‘an actor’. So this would need to be expressed as two separate phrases:

so rather than

Report an actor which is an animal jumping:

which would exclude the player,

Report an actor jumping:
	if the actor is an animal:

which would include the player

Or, you could do the same in one phrase by including the extra condition after ‘when…’ :

Report an actor jumping when the actor is an animal:
1 Like

For the record, the only ‘descriptions of objects’ which DO match the player as actor in an action pattern are:

no actor specified => the actor is whichever object is currently the player, e.g.

Report jumping:

an actor => any object matches as actor, including the player, e.g.

Report an actor jumping:

the player => whichever object is currently the player, e.g.

Report the player jumping:

yourself => whichever object is currently the player, whether or not that is the self object, e.g.

Report yourself jumping:

Note that a specified named object as actor will NOT match the player, even if the player is currently that named object, so that

Report Bob jumping:

will never match the player even if the player is currently Bob.

Likewise if an object variable other than the player is specified as the actor, even if that object variable currently holds the same object as the player variable, so

Report the king jumping:

will not match the player even when the king object variable is the player.

Note also that only the exact words ‘an actor’ are special-cased to match any object:* ‘the actor’ or ‘actor’ refer only to the actor variable, so

Report the actor jumping:

will, like in ‘the king’ example, not match the player even when the actor is the player.

* ‘an actor’ is special-cased by omitting any test for the actor from the compiled I6

3 Likes