Howdy!
I’ve been tinkering with I6 on and off for a couple of years. I completed one adventure (“Radley Manor”) and am working on another, much more ambitious one.
One of the puzzles involves making a pot of coffee with a big old coffee maker. You need to put in grounds and water, turn the machine on, and put a mug into a receptacle.
I can’t get the “if the empty mug is put into the receptacle, and the other conditions are met, replace the empty mug with a full mug” to work.
Is there a bit of sample or example code out there someone could recommend?
And a general question . . . if I put a bit of code here for comments, can I still enter the overall piece in competition?
Thanks
Stefan
OK, I figured it out. The problem with my initial design was a dumb syntax error.
I was using the condition:
coffee_maker.on
Rather than:
coffee_maker has on
Here is the implementation. The “coffeed” and “watered” attributes get set by using a coffee can and a water can, respectively.
Object mug_empty “coffee mug” mess_hall
with name ‘mug’ ‘coffee’,
description “It’s a white earthenware coffee mug, built to last.”,
initial “A coffee mug sits on the end of the counter.”,
each_turn [;
if(self in coffee_maker_receptacle && coffee_maker has on)
{
remove self;
move mug_full to player;
print “A stream of coffee fills the mug, which you take.”;
}
return true;
]
;
Object coffee_maker “coffee maker” kitchen
with name ‘coffee’ ‘maker’ ‘urn’ ‘percolator’,
watered false,
coffeed false,
brewing false,
ready false,
firstlook true,
description
[; print “Standing by the kitchen door is a big industrial grade percolator.”;
if (self.firstlook)
{
print “The cylindrical machine is stained and beaten up through long use. Camp counselors are allowed to serve themselves right from the machine, but coffee is off-limit to campers. Once, on a dare, one of the bigger Wolf Lodge guys snook in and tried to take a mug full. He got in big trouble!^”;
self.firstlook = false;
}
print "The coffee maker has hopper for ground coffee ";
if (coffee_maker.coffeed==true)
print "(which is full), ";
else
print "(which is empty), ";
print "a brewing done light ";
if (coffee_maker has on)
print "(which is lit), ";
else
print "(which is off), ";
print "a water meter ";
if (coffee_maker.watered==true)
print "(which shows full), ";
else
print "(which shows empty), ";
print "and a receptacle for a coffee mug ";
if (mug_empty in coffee_maker_receptacle)
print "(which has an empty mug in it). ";
else if (mug_full in coffee_maker_receptacle)
print "(which has a mug of steaming coffee in it). ";
else
print "(which is empty). ";
],
before
[;
SwitchOn:
if (coffee_maker.coffeed && coffee_maker.watered)
{
give coffee_maker on;
print "The indicator light turns on. A gurgling sound comes from within the machine. ";
!start timer
return true;
}
else
{
print “The indicator light stays off and the switch flips back to the ~off~ position. Perhaps the percolator doesn’t have everything it needs to make coffee?”;
return true;
}
],
has static switchable
;