Monitoring player actions via Daemon

This originally started as an entirely different issue, which I included below. Halfway through writing the example and help request, I got an idea of how to solve it, but I don’t know if what I need is possible.

Question: Is it possible for a Daemon to check what action, or rather, if a specific action, is performed by the player each turn? Not through what effects that action may have, but by actually checking if the player has or hasn’t performed a specific action in each turn.

Why do I want to do this? Well, see below:

The idea is to make certain repetitive actions display one message the first time you carry them out and a second type of message every successive time. This is simple enough to do via a StopEventList, but there is one situation this does not account for: If the player stops performing this action, does something else, and then goes back to performing the action, the text should reflect the fact that he’s not continuing the action, but retaking it.

For instance, suppose the player’s hitting a training dummy (This is just for example, that’d be one boring-ass task in an actual game):

trainingRoom: Room 'Training Room'

dummy: Thing 'training dummy' 'training dummy' @trainingRoom 
    "It's a wooden training dummy."

hitingTheDummyList: StopEventList
        'You begin practicing on the dummy. ',
        'You continue striking the dummy. '

Using this, the first time you hit the dummy, the first message in the list will show up, and the second one every time afterwards. Simple enough. However, if you go do anything else and then go back to hitting the dummy, only the second item in the list will appear. In order for the descriptions to make sense, it would be ideal if the first message shows up when you strike for the first time, the second message every successive time after that, and if you perform any other action, the first message should show up again when you start hitting the dummy again. Now, this is just a sample of the situation, I could solve this particular instance of the problem with some creative phrasing.

What I’d like is for this list to keep repeating the last message when it’s being executed over and over, but restart from the beginning if the player does anything else but trigger the list’s doScript.

Anyhow, to sum it up: I need something that behaves like a StopEventList when it is being executed in succession, but restarts from the beginning when something else besides the list is executed. The only two things that occurred to me were adding a check to EVERY OHER POSSIBLE ACTION in the room to reset the list (yeah… no), and, more realistically, a Daemon that triggers when the list’s doScript is first fired, and checks what action I perform every turn, resetting the list and shutting itself off as soon as I do something else besides trigger the doScript, only to fire again when the doScript is triggered again, keep checking until the player does something else besides triggering the doScript and so on and so forth…

That is easy to do by remembering the current turn when the action is performed. Before you do that, you compare the current turn count to the saved one. If they differ by exactly 1, then this means the player performed the same action in the previous turn.


[code]Thing {
‘doodle’ ‘doodle’
"A doodle. "

lastTurnTaken = 0;

        if (libGlobal.totalTurns - self.lastTurnTaken != 1) {
            "First time. ";
        } else {
            "Continuing. ";
        self.lastTurnTaken = libGlobal.totalTurns;


Could you do a similar check within the List itself (since EventLists can include functions)?

You might consider using roomBeforeAction in the room. Test the value of gActionIs and the value of gDobj. If you don’t get the action of attacking and the dummy as the dobj, reset the counter (I forget its name – you can look it up in the LRM) for the EventList.

Yes, I just tried it. In a StopEventList modified usng the code bcressey showed me in here, I just added the turn check in the list’s check() stage like so:

hitingTheDummyList: StopEventList [ 'You begin practicing on the dummy. ', ] altList = [ 'You continue striking the dummy. ' ] check() { if (libGlobal.totalTurns - lastTurnTaken != 1) restarting = true; else restarting = nil; self.lastTurnTaken = libGlobal.totalTurns; if (restarting == nil) return (nil); else return (true); } restarting = true lastTurnTaken = 0 ;

That about covers the behaviour I care for and allows me to make subclass of StopEventList that always follows this pattern if I wish it to. I didn’t reset the list in this example because I didn’t need to after all (this makes things more convenient for my purposes, in fact).