I’ve implemented a remote-controlled cart which can be sent from place to place with the command MOVE CART [DIRECTION]. I’d like it to also respond to the command CART, GO [DIRECTION], analogous to commanding an NPC, but Inform doesn’t like this grammar because it contains a comma. Any way around that? (I did think of making the cart a person, but that doesn’t work because I want it to be a container.)
There’s a built-in extension called Inanimate Listeners that will do what you want. It allows you to define an object with the addressable attribute (equivalent to the Inform 6 talkable attribute).
Include Inanimate Listeners by Emily Short. The Start Room is a room. "This is the start room." The remote-controlled cart is here. The cart is an addressable open container. [Your definition of MOVE CART [DIRECTION] goes here. I've assumed that you called the action "moving it to".] Instead of asking the cart to try going: try moving the cart to the noun.
A person can also be a container if a part of them is a container. (Imagine a person wearing pants which have pockets [which are containers])
Therefore you COULD make a person a container if a part of them was a CONTAINER…
NOTE: the player doesn’t have to be WEARING pockets for pockets to be part of them.
The Living Room is a room. Dave is a male person. Dave is in the Living Room. Pockets are a part of Dave. Pockets are a open container.
I’ve tried using the Inanimate Listeners extension, but I get this error:
Problem. You wrote ‘Include Inanimate Listeners by Emily Short’ but I can’t find that extension, which seems not to be installed. (You can get hold of extensions which people have made public at the Inform website.)
But when I go online to look for it, apparently it’s supposed to be built in.
Hm…which version of Inform are you using?
Inform 7. Are there more recent updates I might be missing?
I think he was asking which release of Inform 7 you’re using. Each release has a 4 character identifier. The most recent ones are: 6M62, 6L38, 6L02, and 6G60.
On the Mac version of Inform, you can find the release ID via the Inform->About menu option. I expect that it’s something similar on Windows or Linux.
Aha–installing the most recent version of Inform makes it work.
Related question: how can I talk to an addressable object that’s in another room?
You need to put it in scope somehow.
And then you probably want to block actions that apply to it, so the player won’t be able to examine it when it’s in another room.
Hmmm… the way to do that would be tricky, since I don’t think you can check whether the cart is visible–once you’ve put it in scope it is visible. What I would try would be to make a privately-named thing that is part of the cart (like the “appearance of the cart”), and block actions where the cart is the first or second noun when the appearance of the cart is not visible. Don’t have time to try to mock this up now. Also that fact that it’s what I would try doesn’t entail that it’s a good idea.
Here’s an attempt at handling the scope issues:
Include Inanimate Listeners by Emily Short. The Near Room is a room. "This is the near room." Things can be remotely moveable. The remote-controlled cart is here. The cart is an addressable remotely moveable open container. The player carries the remote control. The Middle Room is north of Near Room. "This is the middle room." The Far Room is north of Middle Room. "This is the far room." Understand the command "move" as something new. Moving it to is an action applying to one thing and one visible thing. Understand "move [something] [direction]" or "move [something] to [direction]" as moving it to. The moving it to action has a truth state called initially present. Setting action variables for moving: if the noun is in the location of the player: now initially present is true. [generic moving it to behavior] Check moving it to: if the noun is not remotely moveable: instead say "You can't move that remotely."; if the room second noun from the location of the noun is nothing: instead say "[The noun] can't go that way." Carry out moving it to: move the noun to the room second noun from the location of the noun. Report moving it to: say "[The noun] moves [second noun]." After deciding the scope of the player: repeat with item running through remotely moveable things: place item in scope. Rule for reaching inside a room when moving something to: allow access. Before doing something other than asking or moving to a remotely moveable thing (called T) when T is not in the location of the player: instead say "[The T] isn't here." [cart-specific behavior] Before moving the cart to: if the player does not carry the remote control: instead say "You don't have the remote control."; if the room second noun from the location of the noun is nothing: say "The remote control flashes, and "; if the cart is in the location of the player: instead say "[the cart] runs into the [second noun] wall with a thud."; else: instead say "you hear a distant thud as [the cart] runs into something." After moving the cart to: say "The remote control flashes, and "; if initially present is true: say "[the cart] rolls off to the [second noun] with a whirr."; else if the cart is in the location of the player: say "[the cart] rolls in from the [opposite of the second noun] with a whirr."; else: say "you hear [the cart] roll [second noun] with a distant whirr." Instead of asking the cart to try going: try moving the cart to the noun. Test me with "x cart / cart, n / x cart / drop remote / cart, n / take remote / cart, n / cart, n / cart, s / cart, s / cart, s"
Actually, as a result of other design decisions in the game, I think I’m OK with the player examining things not in the room.
The extension Scope Control lets you put things in scope only for specific reasons: so you can add it to scope when “parsing for persuasion” but not when “parsing the nouns”.