Getting the name of an object printed in a stock response

Hey All-
My question du jour is:
I can’t figure out how to get the name of an object printed in a stock response to an action that’s one turn removed from the action.
Here’s the code:

Instead of elating something (this is the elating rule):
	say "It rises in the air.";
	something falls in one turn from now.

At the time when something falls:
	say "[The noun] falls."

So the idea is that the thing rises, and falls down after one turn, and of course I’d like the game to say “the chest falls” or “the hat falls”, depending on what was elated. But the code the Documentation taught me (using “The noun”) produces this text in the game:

elate chest

It rises in the air.

z

Time passes.

nothing falls.

And I think this is because of the turn in between rising and falling. Can someone help me figure this out? Because having the game tell you “The elated object falls” is pretty lame.

I don’t think there’s a built-in way of doing this, you’ll need to keep track of the elated object yourself:

"Falling Objects"

The lab is a room. "Bubbling retorts, that kind of thing."

The box, the computer, and the table are in the lab.

Elating is an action applying to one touchable thing.
Understand "elate [something]" or "lift up/-- [something]" or "levitate [something]" as elating.

The elated object is an object that varies.

Check elating something:
	if the elated object is not nothing, say "You can only muster the strength to elate one object at a time." instead.

Carry out elating something:
	say "You rise [the noun] up into the air.";
	now the elated object is the noun;
	something falls in one turn from now.

At the time when something falls:
	say "[The elated object] falls.";
	now the elated object is nothing.

Note that this falls apart when you try to elate more than one object at once (hence my check rule). You’d need to rig a more complicated system to achieve that, perhaps involving tables or something like that.

3 Likes

Thanks so much- that works like a charm!

In the spirit of a guided tour of relevant features of Inform 7, the following example is a more general treatment that may be of interest. It also contains references to the relevant chapters in Writing With Inform (the built-in documentation) so that you can better see how it works.

Generalized Solution
"El(ev)ated Things"

Place is a room.

A rock is in Place.

A log is in Place.

A thing can be elated. A thing can be about to fall. [See WWI 4.7 New either/or properties.]

Elating is an action applying to one thing. Understand "elate [things]" as elating. The elating action has a list of things called newly-elated items. [See WWI 12.10 Action variables]

Setting action variables for elating:
	let MOL be the multiple object list;
	let N be the number of entries in MOL;
	if N is zero:
		add the noun to newly-elated items;
	otherwise:
		add MOL to newly-elated items.
	
Carry out elating: [See WWI 12.2 How actions are processed. Also see WWI 12.9 Check, carry out, report.]
	now the noun is elated.

The announce items from multiple object lists rule does nothing when the current action is elating. [See WWI 19.5 Changing the behavior of rules]

To decide whether the/-- (X - thing) is the last entry of/in the/-- (L - list of things):
	let N be the number of entries in L;
	if X is entry N in L:
		decide yes;
	otherwise:
		decide no.

[See WWI 21.3 Saying lists of values]
To say The (L - list of values of kind K): [no equivalent in Standard Rules?]
	say "[L with definite articles]" in sentence case.

To say the (L - list of values of kind K): [no equivalent in Standard Rules?]
	say "[L with definite articles]".

To say A (L - list of values of kind K): [no equivalent in Standard Rules?]
	say "[L with indefinite articles]" in sentence case.

To say a (L - list of values of kind K): [no equivalent in Standard Rules?]
	say "[L with indefinite articles]".

Report elating when the noun is the last entry in newly-elated items:
	say "[The newly-elated items] [are] now el(ev)ated."

To fall is a verb. [See WWI 14.3 More on adapting verbs.]

Every turn when something is about to fall (this is the about to fall elated things fall rule): [See WWI 9.5 Every turn.]
	let F be the list of about to fall things;
	repeat with O running through F:
		now O is not elated not about to fall;
	if F is not empty:
		say "[A F] [fall] to the ground."

Every turn when something is elated (this is the elated things eventually fall rule):
	now everything elated is about to fall.

The elated things eventually fall rule is listed after the about to fall elated things fall rule in the every turn rules. [See WWI 19.4 Listing rules explicitly; a safeguard in case the code is rearranged.]

Example output:

Place
You can see a rock and a log here.

>elate all
The rock and the log are now el(ev)ated.

>z
Time passes.

A rock and a log fall to the ground.

>elate rock
The rock is now el(ev)ated.

>elate log
The log is now el(ev)ated.

A rock falls to the ground.

>z
Time passes.

A log falls to the ground.

>
2 Likes

I may be missing something here, but wouldn’t these solutions print a falling message even if the player left the scene?

Yes, they certainly would for mine. Call it an exercise for the reader? (Or just call it a mistake!)

Every turn when something is about to fall (this is the about to fall elated things fall rule): [See WWI 9.5 Every turn.]
    let F be the list of about to fall things;
   	let VF be the list of visible about to fall things;
    repeat with O running through F:
	    now O is not elated not about to fall;
    if VF is not empty:
	    say "[A VF] [fall] to the ground."

And as long as we’re paying closer attention to details:

Before printing the name of an elated thing while doing something other than elating: [See WWI 18.10 Printing the name of something]
    say "el(ev)ated ".

Test me with "elate log / l / elate rock / e / w". [See WWI 24.2 Debugging features to use in source]
1 Like

I hadn’t thought of that, but I’m not sure how much it matters. This is my first game. If it’s any good, I’ll spend time fussing with things like that.
But honestly- how good is anyone’s first game?

Absolutely true (and possibly the reason why I have yet to produce a full I7 game since taking up the language in 2010).

I mean, some are amazing – A Beauty Cold and Austere, Risorgimento Represso, Ether, and Scroll Thief are all great, and I believe Galatea was Emily Short’s first game (or at least first that she published)! So don’t sell yourself short – even if you’re still learning Inform, it’s still more than possible to create a really awesome game first time out.

Of course, putting too many expectations on your rookie effort can be a bad idea, and there’s a lot to be said for having the modest-seeming but actually quite ambitious goal to finish something solid and learn from the process. Everybody’s motivation is different!

Oh, and in the spirit of pointing out additional detail stuff that you may or may not want to worry about right now, you might want to block certain actions while an object is elated, since taking or pushing or pulling it might not make sense while it’s floating:

Before taking something when the noun is about to fall:
	Say "It's floating a little too high up for you to do that!";
	Stop the action.

Or you could take a more blanket approach:

Before doing something other than examining to something when the noun is about to fall:
	Say "It's floating a little too high up for you to do that!";
	Stop the action.

Finally, if the player tries to elate something they’re carrying or wearing, you might want to get it off them as part of the elate action:

Carry out elating:
	if the noun is enclosed by the player:
		move the noun to the location;
	now the noun is elated.

Hope this is helpful!

Well, I’ve played all those except Scroll Thief, and you’re right- they’re great. I didn’t know those were all first efforts! That’s a pretty good pep talk.

But… I think Emily Short is the Mozart of IF- everything is a masterpiece, and she’s probably been doing it since she was five. So not going to consider myself in her league. :grinning:

1 Like