How to verify/check IAction verbs?


Little by little, I’m wrapping my head around this game system. I want to do some verification when the player issues the sleep command.

You don’t need to sleep right now.

npc, Sleep
Npc doesn’t need to sleep right now.

So far, so good. But how can I verify the sleep command for an npc char along the lines of the following pseudo code:

npc: Actor 'npc' 'npc' @someRoom "Npc. "
    isHypnotized = nil
    isAsleep = nil

        if(!isHypnotized)){ IllogicalNow('Npc isn\'t sleepy just now. '); }
        "Npc nods off at your command. ";
        isAsleep = true;

I’ve figured out how to handle verify, check, and the rest for verbs that have direct and indirect objects, but not for IAction verbs. I can’t use dobjFor() or iobjFor(), so where do I put the verify() and action() methods?



Generally speaking actions not involving objects doesn’t have remap/verify/check, only execAction() method on action class. Processing of such action is much simpler because there is no object resolution and disambiguation and so on. In Learning T3 book is even an example of sleep action and this action in turn calls gActor.goToSleep(); so this means you can override goToSleep method of your actor (me or npc).

It’s always best to browse the TADS 3 Library Reference Manual where you can navigate to SleepAction class and click through the link to the source code of the library to see the definition what it does. Do you see the call to goToSleep? Then again you can search Actor class on the left, fing goToSleep and see the definition in source code:

/* * Go to sleep. This is used by the 'Sleep' action to carry out the * command. By default, we simply say that we're not sleepy; actors * can override this to cause other actions. */ goToSleep() { /* simply report that we can't sleep now */ mainReport(&cannotSleepMsg); }

As you can see cannotSleepMsg is printed here, therefore you know that you can either replace the message by setting cannotSleepMsg = "Customized message… " property on Actor or override goToSleep method to do whatever you need.