[MUD-Dev] Re: Verb binding
clawrenc at cup.hp.com
clawrenc at cup.hp.com
Wed Apr 23 17:18:31 New Zealand Standard Time 1997
In <9704241355.7ya5 at ami-cg.GraySage.Edmonton.AB.CA>, on 04/24/97
at 08:44 AM, cg at ami-cg.graysage.edmonton.ab.ca (Chris Gray) said:
>What about a situation like this: there is an apple tree, and you
>want to be able to pick apples from it. I do this by having two kinds
>of apples, one on the tree, and the other in the hand. So, you can
>refer to 'apple' whether or not you have picked one. The 'pick' verb
>is global, so it has no trouble generating a new apple for you,
>whether or not you have one in your hand. How would you guys do this
>with verbs bound to objects? The 'pick' verb on the apple in your
>hand would get called, and its going to have to go out and figure out
>whether an apple tree is nearby, and do the right stuff to generate a
>new apple. This is exactly what a global 'pick' verb does. In that
>case you have to first search for the verb (likely finding it on the
>apple being carried, but perhaps you have some way to force it to
>happen for the hidden on-tree apple), and then the verb has to search
>for a tree.
I handle with one of a few simple approaches:
If I don't care if the apple's state is retained after it is picked
(eg the unpicked apple may contain a worm, but the picked one won't,
or perhaps a message scratched on its skin) I have two different sorts
of apples, one that lives only in the apple tree and has a "pick"
verb, and another non-tree apple.
When an apple is picked, the verb only exists on the tree-type apples,
so that is matched. The verb methods then create a new apple of type
non-tree which doesn't have a "pick" verb, and hand that off to the
user while destructing the tree-apple.
If I do want to retain state (eg I want the worm to still be there
after the apple is picked, or the scratched message), then I merely
have an inherited parent which defines the "picked" verb. Then, when
the apple is picked it disinherits the parent, and the pick verb goes
A variation on this last one occurs when the parent with the "pick"
verb occurs way up the inheritance tree and can't be disinherited due
to other required methods. (This is approach is also probably more
efficient for the last case as well). Create a seperate object which
is associated with the apples, and bears the "pick" verb. If the case
demands it, have one such pick-object per apple. The pick object then
resolves the "pick" verb, the invoked method transfers the location of
the associated apple to the player, and the pick-object
Pleasantly both of these last approaches allow already picked apples
to be placed back in the tree (say lodged atop a branch), AND be
unpickable (but still gettable). Ahh, illusion.
If you really want reaplced apples to be pickable, just put a watch on
the tree's contents, and re-create the original setup )pick-object or
whatever) whenever an apple is placed in the tree.
J C Lawrence Internet: claw at null.net
(Contractor) Internet: coder at ibm.net
---------------(*) Internet: clawrenc at cup.hp.com
...Honorary Member Clan McFUD -- Teamer's Avenging Monolith...
More information about the MUD-Dev