Digging in the ground in TADS (using WorldClass)

5 views
Skip to first unread message

Jarle Brinchmann

unread,
May 28, 1995, 3:00:00 AM5/28/95
to
Hi,

I'm just sitting here fiddling around looking at WorldClass, and I am
trying to make a room where I can dig in the ground, but things don't
work like I want to.

I get the response (from the code below):

>dig in ground
(with the thin, skinny hands)

>


Whereas I would like to have the response:

"You find a stone"

I don't see why I don't get this. Can anyone explain to me what I do
wrong? (I hope so :-)

Here's the relevant part of the code:
(ldesc, sdesc etc. deleted)

------

I have a room like this:

oldtemple: Outside
sdesc = "An old temple"
<...>
ground = softground
;

With softground being a subclass of Ground:

softground: Ground
verDoDigwith(actor, io) = {}
location = oldtemple
<...>
doDig(actor) =
{
"%You% find a stone";
pass doDig;
}
;

I have also defined my hands like this:

hands: Part
<...>
partof = Me
isvisible(Me) = true
istouchable(Me) = true
istakeable(Me) = true
verIoDigwith(actor) = {}
;

Jarle.

--
---------------------------------------------------------------------
Nuke the Whales ! | Jarle Brinchmann,
| Email: Jarle.Br...@astro.uio.no
International Krill Union. | or : jar...@astro.uio.no


David Baggett

unread,
May 29, 1995, 3:00:00 AM5/29/95
to
In article <JARLEB.95M...@procyon.uio.no>,
Jarle Brinchmann <jar...@procyon.uio.no> wrote:

>I'm just sitting here fiddling around looking at WorldClass, and I am
>trying to make a room where I can dig in the ground, but things don't
>work like I want to.

>...


>I get the response (from the code below):
>
>>dig in ground
>(with the thin, skinny hands)
>
>>
>

I'm not sure if this is part of the undesirable behavior you're commenting
on, but there is no easy way to turn off the parenthesized message. You
might reword it to "(with your hands)" by changing the sdesc for your hands
to "your hands", however.

BTW, you have done just the right thing by making the hands object a Part,
with partof = Me. This will nicely prevent the hands from being listed
separately. (Technically, because all Parts have isnoticeable(actor)
return nil.)

>Whereas I would like to have the response:
>
>"You find a stone"
>
>I don't see why I don't get this. Can anyone explain to me what I do
>wrong? (I hope so :-)

Generally: You have made a very common TADS mistake -- you have misused the
io/do methods for a verb that takes an indirect object. The secret is that
the *io* method handles the action, not the do method, as you've written it.

Now for specifics:

>softground: Ground
> verDoDigwith(actor, io) = {}
> location = oldtemple
><...>
> doDig(actor) =
> {
> "%You% find a stone";
> pass doDig;
> }

There are two problems with this. First, there is no doDig method.
WorldClass does not ever call a method called "doDig", because the
command

>dig (in) ground

is not valid -- the player *must* specify an indirect object (what
to dig with). Not all verbs work this way, of course, and you could
easily change the dig verb to accept this syntax. (See below.)

So at the very least you need a "Digwith" method. However, changing
your code to

doDigwith(actor, io) = {
"%You% find a stone.";
}

(you really don't need the pass command) still won't work, because -- and
here is the tricky part -- TADS will call the ioDigwith method, not the
doDigwith method. The rule is that whenever an io is involved, the io
method gets called. *The do method will not get called at all.* (Note that
*both* do and io methods get called in the verfiy pass; in other words,
both verIoDigwith and verDoDigwith have an opportunity to block the
action.)

So you need to add this to your hands object:

ioDigwith(actor, dobj) = {
// have the object we're digging into handle things:
dobj.doDigwith(actor, self);
}

This tells ioDigwith to pass control to the doDigwith method, so you can
keep the main code in the ground instead of in the hands (and use the
doDigwith code above). Of course, the name doDigwith is arbitrary here --
it could have been JRandomDigMethod for all WorldClass cares.

Finally, you should have

verDoDigwith(actor, io) = {}

in your ground, so that the ground will allow itself to be dug into.

One last nitpick:

>hands: Part
>...
> istakeable(Me) = true

This is a bit hacky. I see why you've done it -- the dig verb demands that
the actor be able to take the object he's digging with. However making
your hands takeable probably makes for some weird responses from the game
(if, for example, you try to take your hands).

It might be better to do this:

replace digVerb: Verb
sdesc = "dig in"
desc(obj) = {
if (obj.isplural)
self.sdesc;
else
"digs in";
}
verb = 'dig' 'dig in' 'dig into' 'dig inside' 'dig downin'
'excavate' 'exhume'
doAction = 'Dig'
prepDefault = withPrep
ioAction(withPrep) = 'Digwith'
dorequires = [[&cantouch]]
iorequires = [[]]
;

modify Thing
verDoDigwith(actor, io) = {
"You can dig with your hands -- no need
to use a tool.";
}
;

That way you can just use verDoDig and doDig and keep the command syntax
simple.

Dave Baggett
__
d...@ai.mit.edu ADVENTIONS: Kuul text adventures! Email for a catalog.
"Mr. Price: Please don't try to make things nice! The wrong notes are *right*."
--- Charles Ives (note to copyist on the autograph score of The Fourth of July)

Reply all
Reply to author
Forward
0 new messages