Recording text + time of day (eg. 273 variation)

Based on the example 273 “If it hadn’t been for… ,” where a recorder registers text associated with actions as well as the time that the actions happen and plays it all back later, I attempted to record entries in which the time of the recording is incorporated in the text itself, thus playing back a report of eg.

At first, using a ‘to record’ phrase similar to that of the above example, I tried:

Instead of attacking a thing: say "You break [the noun] in pieces."; record "The detective says: 'At [time of day], the suspect broke [a noun].'"
… but this resulted in reporting the time of the report, not the time of the breaking/recording.

Then, I tried:

Instead of attacking a thing: say "You break [the noun] in pieces."; let the current time be the time of day; record "The detective says: 'At [current time], the suspect broke [a noun].'"
… which actually works.

Still, for the sake of economy, since I call the record phrase many times in the code (eg. instead of drinking something, instead of touching something…), I was wondering if there could be a way of getting rid of the “let the current time…” line, by changing/adding something to the record phrase itself.

Is there?

Well, this is what the “time stamp” in the Example is for. Here’s an adjusted version.

Table of Breakages
Time stamp (time)	Breakage (thing)
with 60 blank rows.

To record (target - a thing): 
	if the number of blank rows in the Table of Breakages is 0, rule succeeds; 
	choose a blank row in the Table of Breakages; 
	now time stamp entry is the time of day;
	now the breakage entry is target.

Instead of attacking a thing:
	say "You break [the noun] in pieces.";
        remove the noun from play.
	record the noun.

To list crimes:
        repeat through the Table of Breakages:
         	say "At [time stamp entry], the subject broke [a breakage entry]."

If you prefer something more like your current code, you could use the “substituted form” operator:

Instead of attacking a thing:
	say "You break [the noun] in pieces.";
	record the substituted form of "The detective says: 'At [time of day], the suspect broke [a noun].'"

Or the “substituted form of” bit could be built into your “To record” phrase instead:

To record (T - a text):
        let S be the substituted form of T;

Also, be aware when using “Instead of attacking a thing” that it will not actually carry out the action unless you reproduce what the parser does because you’ve interrupted it.

It would be better to make these “Carry out” rules which happen when the action will succeed and the world is being manipulated.

I see that this was included in the example - moving the object off stage and saying it’s broken. However, I believe this won’t go through standard checks such as if the room is dark, if the object is in a transparent container…etc. It also will register that the action failed.

Hi jrb

Yes, I thought of the [time stamp entry] but I couldn’t use it within the ‘occurrence’ text, when calling the record phrase. I want the ‘occurrence’ text to be a whole paragraph, not just the item.

So, yes, I guess the ‘substituted form’ will do the trick!

Hi Hanon,

Good point!

Thanks, as always!

To add on to Hanon’s suggestion, I’d actually make these “after” rules (which run after the action has succeeded but before it’s reported). That way you can record any changes in world state. Just remember to include “continue the action” so that the action still gets reported as usual.

Indeed! Thanks, Draconis!