can't pour pourable item onto valid food object (adv3Lite)

Harry takes a bottle of dressing and a head of lettuce from the refrigerator and tries to pour the dressing on the lettuce.

He can’t. I don’t see why not. Both items are Food objects. The lettuce has canPourOntoMe = true, the dressing has isPourable = true. What else do I need?

From the game window…

…based on this code…

#charset "us-ascii"

#include <tads.h>
#include "advlite.h"

versionInfo: GameID
    IFID = '445C38A3-AD1B-4729-957A-F584600DE5C1'
    name = 'test'
    byline = 'by Jerry Ford'
    htmlByline = 'by <a href="mailto:jerry.o.ford@gmail.com">
                  Jerry Ford</a>'
    version = '1'
    authorEmail = 'Jerry Ford <jerry.o.ford@gmail.com>'
    desc = 'Testing salad dressing'
    htmlDesc = 'Testing salad dressing.'

;

gameMain: GameMainDef
    /* the initial player character is 'candidate' */
    initialPlayerChar = harry
    paraBrksBtwnSubcontents = nil
   
;

// harry, main character
harry: Actor 'Harry;;man self;him' @kitchen
    ""
    globalParamName = 'harry'
    person = 3   
;

kitchen: Room 'Kitchen' 'kitchen'
    "The kitchen. <.p>"
;
+ headOfLettuce: Thing, Food, Surface 'head of lettuce;;lettuce salad'
    "<<one of>>The produce compartment contained <<or>>Harry saw <<stopping>>a 
    head of lettuce, previously washed, chopped and bagged for later. "

    canPourOntoMe = true
    hasDressing = nil
    
    hideFromAll(action) { return true; }
    dobjFor(Eat)
    {
        action()
        {
            if(headOfLettuce.hasDressing)
                "<q>Hmmm (munch, munch),</q> Harry mumbled while eating the
                lettuce. <q>That's pretty good dressing.</q> <.p>";
            else
                "<q>Hmmm, (munch, munch) not bad,</q> Harry mumbled while
                eating the lettuce, <q>but next time maybe I'll try it with
                dressing.</q>";
            inherited;
        }
    }
;
+ saladDressing: Thing, Food 'bottle of salad dressing;salad;dressing bottle'
    "Harry could see a bottle of oil-and-vinegar dressing<<if
      saladDressing.location == refrigerator>> on the shelf on the inside of
    the refrigerator door<<end>>. "
    
    isPourable = true
    headOfLettuceDressed = nil
    
    hideFromAll(action) { return true; }

    dobjFor(Drink) asDobjFor(Eat)
    dobjFor(Eat)
    {
        action()
        {
            "<<one of>>Harry opened the bottle and drank the dressing. <q><i>Urp,</i> might've
            been better poured on the lettuce,</q> he murmurred. <<or>>The
            bottle was empty.<<stopping>> <.p>";
        }
    }
    dobjFor(PourOnto)
    {
        /*
        verify()
        {
            if(gIobj == headOfLettuce)
                illogical('Boo!');
        }
        */
        action()
        {
            if(gIobj == headOfLettuce)
            {
                headOfLettuce.hasDressing = true;
            }
            inherited;
        }
    }
;

Additionally, I have put dummy verify() trap in the salad dressing’s dobjFor(PourOnto) code, currently commented out. It’s there so that I can see the action in the debugger. When it’s not commented out and a breakpoint is set on the if(gIobj == headOfLettuce) line, the debugger stops there, then when let go prints the illogical text. Why is that? The gIobj—the head of lettuce (verified in the debugger)—is a valid item of food, with the can pour onto me flag set. Why is the illogical message being used for this item?

Actually, gIobj is verified as headOfLettuce only once, on the second trip through the verify() code. The first time through, it’s nil then when I hit f5 to continue processing, it immediately stops on that line again and gIobj is now the head of lettuce. Hit f5 a second time, and the illogical text is printed out.

Jerry

Not sure about adv3Lite, but in standard T3 it’s expected that gIobj will have a value of nil the first time through the verify() routine, because at that stage the parser hasn’t figured out what the objects are.

Try using a check() routine rather than verify() to make sure the dressing is being poured onto the lettuce. (You’ll find more about the logic of this in the T3 manual, in the Technical Manual, in the article “Verify, Check, and When to Use Which”.

Yes, I am aware that verify() can be called multiple times with different values in play. And I did try check() before I posted the original message. The only reason I resorted to verify() was to get something to show up in the debugger.

Actually, that’s the only reason for using either of these functions—to check on progress through the code.

Shouldn’t pouring from an object on which the isPourable flag is true onto an object for which the canPourOntoMe flag is true just work? Without an override in the code?

Unless there’s another flag I need to set.

Jerry

It seems so (in thing.t):

/* * The allowPourOntoMe property controls whether we want allow anything to * be poured onto this thing (even if it's possible). By default we don't. */ allowPourOntoMe = nil

Minghua:

Yes, that’s it. Thanks.

Armed with that knowledge, I now see both allowPourOntoMe and canPourOntoMe listed as properties for Thing in the library reference.

It works now.

Jerry