VerDoCut: Problems

Hi,

I tried R.A.I.F first, but apparently no one there knows what to do about this, because I got no replies.

I’m having a problem in TADS 2. I’m trying to implment a puzzle in
which the player cuts
a curtain of vines, in order to continue down a path. But when I test
it, I get a “I don’t
know how to cut the vines” for just “cut vines” and I get a “I don’t
understand that sentance”
with “cut vines with machete”.

As far as I know, I’m coding it correctly. Does anyone see a problem
with this implamentation?
(I’ve done the verbs, so that’s not the problem).

Code*******************************­*********

island3_jungle_northPath_vines: fixeditem
isCut=nil
sdesc=“vines”
ldesc=“This curtain of vines is twisted, thick, green, and dangerous
looking.”
noun=‘vines’ ‘vine’
adjective=‘curtain’
location=island3_jungle_northPath
verDoCut(Me)=
{
if (self.isCut=true)
{
“It’s already quite butchered, thank you.”;
}
else if (island1_machete.location!=Me)
{
“You don’t have anything to cut it with.”;
}

}

doCut(Me)=
{
“You hack unskillfully away at the vines, feeling adventureous. After
nearly a minute, you come
out the other side, twirling your machete, nearly slicing your foot
off.”;
self.isCut:=true;
return(island3_jungle_northPath_further);

}

ioCutWith (actor, dobj) =
{
if (self.isCut=nil)
{
if (dobj=island1_machete)
{
“You hack unskillfully away at the vines, feeling adventureous.
After nearly a minute, you come
out the other side, twirling your machete, nearly slicing your foot
off.”;
self.isCut:=true;
return(island3_jungle_northPath_further);
}
else
{
“<<dobj.thedesc>> is not exactly the correct tool for the job.”;
}
}
else
{
“The vine curtain is already cut.”;
}

}

;

Code
End
*****************

Thanks,
James

It seems that the problem lies in the verb definition you didn’t show here. It should look similar to this one:

cutVerb: deepverb
    verb='cut'
    sdesc="cut"
    doAction='Cut'
    ioAction(withPrep)='CutWith'
;

Let’s start with the “cut vines” command. The message you get hints at the fact the suffix of the handler
methods names you chose (Cut) don’t match the doAction property of your definition for the verb “cut”. I suspect
you wrote something like doAction=‘cut’ (since it’s the most common error). Again, it should match the name
prefix of the handlers exactly - including the letter capitalisation. Please check it one more time.

The message you get for “cut vines with machete”, again, means you haven’t defined the ioAction at all or
defined it the wrong way. It should be exactly as shown in my example (the withPrep argument means you use
the command “cut” with the preposition “with”, and ‘CutWith’, again, is the exact match for your chosen
handler method name suffix.

But I see one more problem with your handlers definitions for “cut vines with machete”. In this command,
“vines” is the direct object, and “machete” - the indirect object. Thus, you need the following verifiers/handlers
methods:
verDoCutWith(actor, iobject) - for vines (it could do the same as verDoCut)
verIoCutWith(actor) - for machete (it could do nothing)
ioCutWith(actor, dobj) - for machete; it could call a method in vines - a common practice - like this:

ioCutWith(actor, dobj)={dobj.doCutWith(actor, self);}

Also, you’d have to rename you ioCutWith method in the vines object into doCutWith.

Please tell me whether this answer was of any help for you.

Thanks, I’ll give it a try!

Hi,

I think I read that wrong, as when I test it, I get a TADS error message:
wrong number of arguments to user function “island3_jungle_northPath_vines.verDoCut”

Is this correct?

CODE START****************************************
island3_jungle_northPath_vines: fixeditem
isCut=nil
sdesc=“vines”
ldesc=“This curtain of vines is twisted, thick, green, and dangerous looking. You could probably cut it if
you had the correct tool.”
noun=‘vines’ ‘vine’
adjective=‘curtain’
location=island3_jungle_northPath
verDoCut(Me)=
{
if (self.isCut=true)
{
if (island1_machete.location<>Me)
{
“You don’t have anything to cut it with.”;
}
else
{
“They’re already quite butchered, thank you.”;
}
}
}
doCut(Me)=
{
“You unskillfully hack your way through the vines, feeling adventureous. You eventually come
out the other side, and continue east, twirling the machete and nearly cutting your toe off.\b”;
self.isCut:=true;
Me.travelTo(island3_jungle_northPath_further);
}
verDoCutWith(Me, dobj)=(self.verDoCut)
doCutWith(Me, dobj)=(self.doCut)
;

island1_machete: item
sdesc=“machete”
ldesc=“It’s a brand new machete, with a rubber grip and a steel guard. Looks quite expensive.”
noun=‘machete’ ‘blade’ ‘sword’
location=island1_beach_w
verDoTake(Me)=
{
if (island1_bird.location=nesthole)
{
“You reach for the machete, but the bird snaps his beak, and you hastily withdraw.”;
}
else
{
“Taken.”;
self.moveInto(Me);
}
}
verIoCutWith(Me)={}
ioCutWith(actor, dobj)={dobj.doCutWith(Me, self);}
;

cutVerb: deepverb
verb=‘cut’
sdesc=“cut”
doAction=‘Cut’
ioAction(withPrep)=‘CutWith’
;

CODE END*********************************

Thanks very much,
James

Not entirely;).

I assume you get the said TADS message when you type “cut vines with machete.” That’s because the following methods in your island3_jungle_northPath_vines should be rewritten as follows:

verDoCutWith(Me, dobj)=(self.verDoCut(Me))
doCutWith(Me, dobj)=(self.doCut(Me))

Previously, you called verDoCut and doCut without arguments, that was the problem.

Besides, verDoCut should be rewritten, too - currently, it doesn’t do the verification properly. That’s how it should look:

verDoCut(Me)=
{
if (self.isCut=true)
    {
"They're already quite butchered, thank you.";
    }
else if (island1_machete.location<>Me)
{
"You don't have anything to cut it with.";
}
}

Oh, and there seems to be one more problem with your code - the verDoTake method of the machete object. Change your definition

verDoTake(Me)=
{ 
if (island1_bird.location=nesthole)
{
"You reach for the machete, but the bird snaps his beak, and you hastily withdraw.";
}
else
{
"Taken.";
self.moveInto(Me);
}
}

to just

verDoTake(Me)=
{ 
if (island1_bird.location=nesthole)
{
"You reach for the machete, but the bird snaps his beak, and you hastily withdraw.";
}
}

The default doTake method inherited from the item class will take care of the rest.

One of the rules of TADS programming says, you should never change anything (setting variables, moving objects, etc.) in verifier methods (that is, methods whose names begin with ‘ver’). They only should check conditions, and display messages. This is because those methods are often called by the system “silently” (with their messages sent to the display being suppressed), which can result in unpredictable game state changes you’re not even aware of. This, in its turn, may lead to errors that are very-very hard to track down.

It works now. Wow, been stuck on that for over a month, thanks a lot.