[adv3lite] Getting dobjFor behaviours working with a class.

So, I have this code:[code]/// Ghost NPCs are defined by the claGhost class. As NPCs, they inherit from the Actor class. As ghosts, there’s a lot they can’t do (such as pick up items and the like).
class claGhost: Actor ‘;;spirit spook ghost;’
{
dobjFor (Feel)
{
check ()
{
inherited;
“<.p>You can’t touch <>; this is because, being a ghost, <> {is} ephermal.”; // You cannot touch a ghost.
}
}
dobjFor (Kiss)
{
check ()
{
inherited;
“<.p>You can’t kiss <>; this is because, being a ghost, <> {is} ephermal.”; // You cannot touch a ghost.
}
}
}

npcShamus: claGhost ‘Shamus;;;’
{
location = romAutopsyExaminationRoom
isHim = true
}[/code]

The dobjFor (Feel) works; the one for Kiss does not. I don’t quite get why, other than it’s probably something simple I’ve overlooked (i.e., maybe having to modify Actor directly?).

Any advice here, please?

Add this to your ghost class definition…

isKissable = true

Alternatively, you could dispense with the dobjFor macros and just set the cannotKissMsg and feelDesc properties on the ghost class…

cannotKissMsg = 'your can't kiss a ghost message'  // note single quotes
feelDesc = "your can't feel a ghost message"         // note double quote

Jerry

The feelDesc property works as expected, but I cannot get “kiss” to work using that method either (I just get the default “That hardly seems appropriate” message).

By the way, it’s spelled ‘ephemeral.’ Also, according to my Webster’s, it means temporary or fleeting. It doesn’t mean intangible or physically tenuous. It’s a nice word, but I think it only applies if your ghost puts in a brief appearance and then is gone before you can touch him or her.

Sorry, should have tested first. I also cannot get a custom can’t kiss message without the dobjFor but that solution does work if you also set both the isKissable and allowKiss properties to true.

This works for me—I did in fact test it, this time :slight_smile:

[code]class Ghost: Actor
vocabWords = ‘ghost’
cannotKissMsg = ‘You can’t kiss a ghost.<.p>’
isKissable = true
allowKiss = true

dobjFor(Kiss)
{
    check()
    {
        "You can't kiss a ghost. <.p>";
    }
}

;
[/code]

Jerry

At least someone has been helpful on this thread. Thanks, jford! Much appreciated. Curious as to why two properties are required though.

I’m speculating, but there appears to be a bit of the new kid on the block bumping up against a bit of the old school.

I believe isKissable is a carry over into the adv3Lite library from the original adv3 library, while allowKiss seems to be related to a KissTopic conversation object that is new in adv3Lite.

If you remove all but allowKiss from the Ghost class, then add a KissTopic to an instance of the class, you can get the same results…

[code]class Ghost: Actor
vocabWords = ‘ghost’
allowKiss = true
;

theGhost: Ghost ‘ghost’ @room
desc = “The ghost.<.p>”
;

  • KissTopic
    “You can’t kiss a ghost.<.p>”
    ;
    [/code]

Unfortunately, it does not appear possible to can add a KissTopic to the class—it generates a nil object reference error when I try to compile. So, you would have to add a KissTopic to each ghost instance, or do it the new kid/old school mashup way, using both isKissable and allowKiss and the dobjFor() macro.

Jerry

Actually, all you need is:

class Ghost: Actor
    shouldNotKissMsg = 'You can\'t kiss a ghost.<.p>'
;

Stiil, having isKissable on Thing and allowKiss on Actor does look a bit odd. I don’t think this is anything to do with a collision between adv3 and adv3Lite; I suspect at some point in the past allowKiss was meant to rule out kissing at the check stage rather than the verify stage and this got changed when an early collaborator wanted me to minimize the use of check(). Since the result is a bit illogical I’ll look into changing it for the next update.

Thank you, Eric. Shall keep an eye out for the next version then.

When I looked into it I ended up making more extensive changes than I at first envisaged. If you’re interested you can find them at GitHub. Note, however, that this is not an official release (and lacks some of the features of a full release, notably the Library Reference Manual); it’s simply intermediate work in progress.

The version on GitHub also incorporates some changes to the way the GO TO command is handled in certain cases, largely in response to the problems Jerry experienced (and then some related cases I could also see might arise).