TADS 3 Beginner Help

#1

I’ve just started using TADS 3 to make IF and I’m having a bit of trouble with my very first scene. I’m trying to make it so when the player sleeps it moves them from the starter room (a room with no exits) to the “real start” of the game in a different room. This is the code the guide I looked up was telling me to do, but its just not having any effect. I’d appreciate any help.

[code]startRoom: Room
roomName = ‘Falling Asleep’
desc = “You are lying in bed. The light breeze of the box fan beside you is comforting
in the summer heat as you slowly drift into slumber.”
dobjFor(Sleep) remapTo(TravelVia, goToBed)
;

  • bed: Fixture
    name = ‘bed’
    desc = “You bed is worn and indented from years of use, but is nonetheless comfortable.”
    //dobjFor(Sleep) remapTo(TravelVia, woods)
    ;
  • me: Actor
    ;

goToBed: TravelWithMessage
travelDesc = “Sights and images flutter before your eyes as your mind rewinds the
memories of the past day, yet as each ends, the next is fainter and more abstract
than the last. Your mind fades dimmer and dimmer until…”
;[/code]

0 Likes

#2

Sleep is not a transitive action. Meaning you can’t use “sleep on/in object”. You can only use “sleep” without an object. So it can’t have a dobjFor handler.

If you look at the actions.t library file, you’ll see that the Sleep action is defined like this:

DefineIAction(Sleep) execAction() { /* let the actor handle it */ gActor.goToSleep(); } ;

So you need to override the goToSleep() method of the player character. Like:

+ me: Actor
    goToSleep()
    {
        if (isIn(startRoom) {
            "Sights and images flutter before your eyes as your mind rewinds the 
            memories of the past day, yet as each ends, the next is fainter and more abstract 
            than the last. Your mind fades dimmer and dimmer until...";

            // Move the player to the destination.
            moveInto(destinationRoom);
            // Show the room description, if the player hasn't seen it yet.
            lookAround(nil);
        }
    }
;
0 Likes

#3

Hey perfect thanks! I’m assuming this applies to anything like that, such as jump or yell or whatever, right?

0 Likes

#4

Depends on the action. “Jump” for example has different actions for each verb form. “Jump”, “jump over object” and “jump off object”. To customize the intransitive version, you’d modify JumpAction. To handle JumpOver and JumpOff, you use dobjFor handlers on the objects.

You can always open the actions.t file and do a search there for the action you’re interested in. In the case of JumpAction, it’s implemented like this:

DefineIAction(Jump) preCond = [actorStanding] execAction() { /* show the default report for jumping in place */ mainReport(&okayJumpMsg); } ;

So if you wanted to customize that, you need to override its execAction() method using a modify statement somewhere in your own code:

modify JumpAction
    execAction()
    {
        if (me.isIn(electric_chair)) {
            "Unlikely. ";
        } else {
            "Whee! ";
        }
    }
;
0 Likes