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