intfiction.org

The Interactive Fiction Community Forum
It is currently Mon Oct 22, 2018 7:04 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Aug 04, 2018 6:08 pm 
Offline

Joined: Wed Jul 25, 2018 8:55 am
Posts: 18
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.

>Sleep
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:

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

    verify(){
        if(!isHypnotized)){ IllogicalNow('Npc isn\'t sleepy just now. '); }
     }
    action(){
        "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?

Thanks


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Aug 05, 2018 2:34 am 
Offline

Joined: Sat Jul 16, 2011 3:48 pm
Posts: 304
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:

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.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group