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