Daemons won't run?

Hello, all. I’m relatively new to TADS 3, and I’m having some difficulty getting daemons to run properly. I’m sure there’s a very simple, obvious solution to this, but I’m just not seeing it.

I can get room daemons to run properly using roomDaemon, but not with any other function name.

I copied the a piece of example code directly from Eric Eve’s Wonderful Learning TADS 3 into an otherwise very plain one room file to see if I could figure out what was going on:

 #include <adv3.h>
 #include <en_us.h>


     gameMain: GameMainDef
       initialPlayerChar = me
     ;

     versionInfo: GameID
       name = 'test'
       byline = 'test'
       authorEmail = 'test <test@test.com>'
       desc = 'Testing '
       version = '1'
       IFID = '4243186C-B4B8-4EF8-9B85-20ACA6EE78A5'
     ;
cave: Room 'small cave'  
     startDrip()
     {
         dripCount = 0;
         dripDaemon = new Daemon(self, &drip, 1);
     }
     stopDrip()
     {
         if(dripDaemon != nil)
         {
              dripDaemon.removeEvent();
              dripDaemon = nil;
         }
     }
     dripDaemon = nil
     dripCount = 0
     drip()
     {
        switch(++dripCount)
        {
           case 1: "A faint dripping starts. "; break;
           case 2: "The dripping gets louder. "; break;
           case 3: "The dripping becomes louder still. "; break;
           default: "There's a continuous loud dripping. "; break;
        }
     }
;

     +me: Actor
     ; 

. . . and while it produces no errors when compiled, the Daemon doesn’t run.

It seems like startDrip() isn’t being called, but I’m not sure how to call it. I’ve tried setting it as equal to something something=startDrip(), which will evaluate if “something” is desc or another value that’s always read, but not otherwise.

As I said, TADS 3 is still a new language for me. Any input you have is much appreciated.

I’m not testing your code, but from a quick look it seems ok. Probably you just need to call cave.startDrip(). You just need to call it by yourself when it is appropriate given your game mechanics. So for example you can add a description for your player character (me object) "You are blah blah… <<cave.startDrip()>> " and then the daemon will be triggered once the player character examines himself (>x myself). Such arrangement is probably not very practical, also you need to ensure your daemon won’t be started multiple times. On what occasion you want your daemon started?

roomDaemon is a special case. It’s a method of the room class, which is automatically called every turn when the player character is in that room. Library does this automatically for you, no need to do anything else just make a method with this special name.

Thank you! For some reason I didn’t think of triggering it like that.
You’re awesome.

As Tomasb said, you need to call startDrip(). What I typically do is use the Room seen property in the description to kick off a daemon only one time. For instance, your cave room could be done this way:

[code]cave: Room ‘small cave’
desc() {
if (!seen) { // if first time in cave
"First time in cave room description. ";
startDrip(); // start the dripping daemon
}
else { // normal room description for 2nd+ time
"Second+ time in cave room description. ";
}
}

 startDrip()
 {
     dripCount = 0;
     dripDaemon = new Daemon(self, &drip, 1);
 }
 stopDrip()
 {
     if(dripDaemon != nil)
     {
          dripDaemon.removeEvent();
          dripDaemon = nil;
     }
 }
 dripDaemon = nil
 dripCount = 0
 drip()
 {
    switch(++dripCount)
    {
       case 1: "A faint dripping starts. "; break;
       case 2: "The dripping gets louder. "; break;
       case 3: "The dripping becomes louder still. "; break;
       default: "There's a continuous loud dripping. "; break;
    }
 }

;[/code]Which produces the following result:[code]small cave
First time in cave room description.

A faint dripping starts.

l
small cave
Second+ time in cave room description.

The dripping gets louder.

l
small cave
Second+ time in cave room description.

The dripping becomes louder still.

[/code]As with most coding, there’s usually more than one way to go about it, but I typically do this when I want to trigger something only one time.

– Mike