Creating a Recall Action Based on Room Name

The idea here is that I’m trying to implement the following concept:

  • Rooms will have a visited summary and an unvisited summary.
  • After the full description is provided once, those summaries are what are provided on every subsequent look.
  • However, I want the player to be able to get the full description back.
  • To do so I will implement a recall verb.

So that’s the basic context. How the “recall” verb should work is:

  • If the player types “recall palace gate”, it should provide the full description of the room called palace gate.
  • If the plater types “recall”, it should assume the player means the room they are currently in.

I started sketching out the basic logic as such:

Recalling is an action applying to one topic.
Understand "recall [text]" as recalling.
Understand "recall" as recalling when the player is in a room.

Carry out recalling:
	if the topic understood is "":
		let the room-name be the name of the location;
	else:
		let the room-name be the substituted form of the topic understood;
	let the room-in-question be the room called the room-name;
	if the room-in-question is a room:
		if the room-in-question is unvisited:
			now the room-in-question is visited;
		say "[description of the room-in-question]";
	otherwise:
		say "You can't recall that room."

This most definitely doesn’t work. In fact, it won’t even compile. But before I dig in further, I’m curious if anyone has thoughts as to whether I’m on the right path for this kind of implementation?

If you only want to recall rooms, and are fine with the message “That noun did not make sense in this context.” when the player tries to recall something else, then I think I’d go with an action applying to one thing and an understand line referring to “[any room]”, like this:

The Lab is a room. "The lab is a place for experiments."

The Corridor is north of the Lab. "The corridor connects the rooms in the facility."

The Supply Closet is north of the Corridor. "The supply closet serves as a storage room for various items."

Recalling is an action applying to one thing.

Understand "recall [any room]" as recalling.
Understand "recall" as recalling.

Rule for supplying a missing noun while recalling:
	now noun is the location.

Carry out recalling:
	say the description of the noun;
	say paragraph break.

Output:

Lab
The lab is a place for experiments.

>recall
The lab is a place for experiments.

>recall closet
The supply closet serves as a storage room for various items.

This doesn’t implement every aspect mentioned in the OP, but it’s one way of laying the groundwork.

3 Likes

Yeah, this is how I’d do things - I might add “recall [something]” as potential grammar, then use a check rule to say “that only work on rooms you’ve visited” if the noun is not a visited room.

(For the OP - the general principle here is that these approaches allow the Inform parser to work for you by telling it with a little more specificity what you want the player to type, i.e. restrict the grammar to actual things in the world model, rather than arbitrary text. I often find that if I’m mucking about with topics understood, usually there’s a simpler way to go rather than basically reimplementing parts of the parser, which is what your initial approach was starting to do!)

Then for the output, I’d give rooms two text properties - “longdesc” and “shortdesc”, say - then have the description of a room always be “[one of][longdesc of the location][or][shortdesc of the location][stopping]”. And then carry out recalling is just saying the longdesc of the noun.

(Apologies, I’m on my phone so can’t easily work this up!)

Edit: also re your initial code, a potential wrinkle that’s good to know is that if the player is in an enterable container or on an enterable supporter, they’re not technically in a room - the “enclosed by” relation is the more general one that catches those issues, so it’s often the one to use.

Edit 2: you might want to check out the Misadventure example, which implements a GO TO [ROOM] action.

3 Likes

This is all really good stuff. Thank you to you both. I definitely see now how I can simplify my idea a bit. I also appreciate the cautionary note regarding “enclosed by”. That was something I was entirely overlooking.

2 Likes

You can suppply a more nuanced error message with this little bit of I6 skulduggery- at the point the error is generated I7 hasn’t decided on a current action (so a condition like if recalling won’t work), but the I6 parser has decided what the current action it’s parsing for is, and this is stored in the I6 global variable action_to_be. The value this holds corresponds to the relevant I7 action name. So:

To decide which action name is the action to be: (- action_to_be -).
For printing a parser error when the latest parser error is the noun did not make sense in that context error and the action to be is the recalling action:
	say "You can only recall locations, not things or concepts."

EDIT: this is an alternative to writing an Understand line applying to “[any object]” and picking up non-room objects the player might type in a check rule, with a similar response- as suggested by @DeusIrae

3 Likes

yet another way to restrict the action proper to visited rooms while customizing the error…

recalling is an action applying to one visible thing.

understand "recall [any visited room]" as recalling.

understand "recall [text]" as a mistake ("[We] [can] only recall rooms [we]['ve] visited.")
4 Likes

Of course I have to do it in a completely hack-y shortcut cheating way:

1 Like

One change I’d make: remember the holder of the player, not the location, so that it doesn’t (e.g.) topple them off their chair.

2 Likes

It threw me for a moment how this worked without having the action apply to one visible thing- surely the action would fail the basic accessibility rule when trying to recall something which couldn’t be touched? Then I recalled @Zed having pointed out some time past that the basic accessibility rule does not apply to rooms or regions.

Non-room objects of course don’t make it as far as an action, being spat out by the parser with ‘That noun did not make sense in this context’