Force actions

Is there a way to force actions. For instance. I have a room description and in the middle of the room description I want the action “read letter” to go off. Hopefully that’s clear enough.

This is a good use for [first time]…[only] in the room description.

[code]The description of Study is "This is a well-appointed study[first time].

You notice an opened letter lying on the table, and you can’t help snooping.

[italic type]Dear Cecily. I burn for the touch of your hand on my cheek. I yearn for the musical bubble of your laughter. I salivate at the thought of your fresh-baked apple tarts.

Always,[line break]Winston

[roman type]Hmn. That’s odd, as they seemed so very married to other people at dinner[only]. Otherwise, the room is unremarkable."[/code]

Then reproduce the letter as an object in the room with the same text.

Sweet! Thank you!

Note also, if you want an actual action to run, with all of the attendant action-processing rules that go with it, you could do something like this:

[code]The description of Study is “This is a well-appointed study[if the letter is in the Study][first time][snoop][only][end if]. Otherwise, the room is unremarkable.”

To snoop:
try reading the letter.[/code]

Strange. When I try that, it errors out and says its look for something to say or a value.

To the original poster: you should absolutely go with your method rather than trying to run an actual action! The following is just a comment on the actual action method.

If you want to trigger snooping from inside a square-bracketed text substitution you actually have to make it a “say” phrase, like this:

[code]The description of Study is “This is a well-appointed study[if the letter is in the Study][first time][snoop][only][end if]. Otherwise, the room is unremarkable.”

To say snoop:
try reading the letter.[/code]

The idea being that when the game encounters the substitution “[snoop]” it thinks it’s a thing to say, and then the say phrase executes the action instead of printing something.

Having actions execute inside say phrases is something that should be handled cautiously (though I’ve tried it sometimes)–there are times when text substitutions get evaluated silently when you wouldn’t expect, so your code can execute when you don’t want it to.

Take this:

[code]Lab is a room. A whatsit is in the Lab. The printed name of the whatsit is “[mystery function]whatsit”.

The mystery count is a number that varies.

To say mystery function: increment the mystery count.

Every turn: say “Mystery count: [mystery count].”[/code]

Every time you look, the mystery count goes up by two rather than one. The reason is that the code to print “You can see a whatsit here” evaluates the printed name of the whatsit once to figure out whether to say “a whatsit” or “an whatsit,” and again to actually print “whatsit.” The “[mystery function]” substitution gets called both these times.

Awesome. Amazing how missing “say” can stop the whole works. :slight_smile:

Oof, you’re right. That was careless of me; sorry.