problems when taking an object from a desk.

Hi, I’m very new to Tads 3 (only day 3) but have been determined to learn it. Have read lots of guides and documentation and followed tutorials to create simple games but am still getting stuck a lot. I’ve managed to get around a lot of things (though I’m sure there are better ways) but there’s one thing I’m very stuck on.

I’m sure it’s simply fixed, I just don’t know how to do it.

ok, here’s the set up. You’re in a room, there’s an area of the room partitioned off. There’s a desk in the partitioned section with a key on it you need. If you try to take the key you are told the glass partition is in the way. There is however a small hole in the partition, so you tell your trusty dog to go get the key. You then get a nice bit of text how the dog leaps through the hole, gets the key and brings it back to you tail a-wagging.

Somehow I’ve managed to make this all work fine. The problem comes if I then drop the key on the floor or anywhere else, and ask the dog to get it. I want it to say the dog has no further interest in the key, but instead I get the same message about him leaping through the hole…

here’s the relevant code I have so far. Sorry if it’s messy but I really am just a beginner.

[code]++ goldKey : Hidden
‘gold key’
‘gold key’
“A gold key.”

dobjFor(Take)
{
    check()
    {
        if((gActor != dog) && (!moved))  //ensures only the dog can pick it up if it's on the desk, and if I drop it on the floor, I won't get told it's behind glass if I try to pick it up again
        {
            "You cannot reach the key through the glass.";
            exit;
        }       
    }
    action()
    {
        inherited;
    }  
} 

;[/code]

Now the dog code:

[code]
dog : Actor
‘Dog’
‘Dog’
@room
“Dog is your best friend. He’s well trained and will obey commands.”
isHim = true
isProperName = true
;

  • TCommandTopic @TakeAction
    matchDobj = [key]
    topicResponse()
    {
    “Dog, <>! you command.\b
    Dog leaps through the hole, picks up the key and brings it back tail a-wagging.\b
    “Thanks Dog.” You tell him, stroking him behind the ears.”;

          keyCard.moveInto(me);
    

    }
    ;[/code]

Here’s the pseudo code of what I’m trying to do… I say pseudo code because I can’t get it to compile…

[code]+ TCommandTopic @TakeAction
matchDobj = [key]
topicResponse()
{
If (key.moved) //if they key has been moved at all… this would stop the dog picking it up from the desk even if the key was on the floor.
{
“Dog, <>! you command.\b
Dog has no further interest in the key and finds something interesting to smell instead”;
}
Else
{
“Dog, <>! you command.\b
Dog leaps through the hole, picks up the key and brings it back tail a-wagging.\b
“Thanks Dog.” You tell him, stroking him behind the ears.”;

        keyCard.moveInto(me);
    }
 }

;[/code]

I tried doing it with a check() action() command like above but it wouldn’t compile, can I not use it there?

Is there a much easier way of doing it?

Thanks in advance for any help, will work on the rest of the game while I’m waiting :slight_smile:

It appears from your code that you should be using goldKey, not key, as the matching object. Or maybe keyCard. I’m not sure about your objects. Also, you’ve capitalized “else”, which will prevent compilation.

Untested, but have you tried something like this:

[code]topicResponse()
{
if (!goldKey.moved) {
“Dog, <>! you command.\b
Dog leaps through the hole, picks up the key and brings it back tail a-wagging.\b
“Thanks Dog.” You tell him, stroking him behind the ears.”;

        keyCard.moveInto(me);
        }
        else "The dog seems to have no further interest in the key. ";
}[/code]

ok, now I do feel really silly. I’d got messed up copying and pasting different parts so I ended up rewriting some of it so don’t worry about the keyCard key goldKey thing that’s all right in the actual code, the problem was indeed capitalising If and Else…

Thank you very much. I’m trying to bugtest every single room and problem before I move on, I can tick that off my to do list and move on the next one. I’ll try and solve them all myself because that’s how you learn, but I’ll probably be back soon with another issue!

Thank you and Merry Christmas! :slight_smile:

There’s a lot to learn in T3. What I sometimes do is start by laying out the map, so all of the rooms are there in a basic form. (That’s not too difficult.) I then start adding puzzles and NPCs, bug-testing as I go.

One other note: You ended your to-be-printed phrase like this:

\"Thanks Dog.\" You tell him, stroking him behind the ears.";

In T3, it’s always a good idea to end a quoted element with an extra space, like this:

\"Thanks Dog.\" You tell him, stroking him behind the ears. ";

This allows the output manager to string quoted bits together and manage the spaces between sentences, if it needs to. In many cases, it will make no difference – it’s just a good habit to get into, because sometimes it DOES make a difference.

For my first game (or test of a game) I’m keeping it short, so only 4 or 5 rooms, a few npc’s, and a nice mix of puzzles to learn how to do different things. Better to start small and work my way up I think :slight_smile:

Thanks for the advice on the strings, I didn’t know about that. I’ve gone through and edited them all now to include the extra space. Thanks for the tip :slight_smile: