Okay, I’m having a weird problem. I want to have the player change a lightbulb. Since the Flashlight + Battery example in the Learning Tads3 manual seemed virtually identical to the behavior I wanted, I copy-pasted the code, changed “battery” to “lightbulb”, etc., and added the Fixture class:
[spoiler][code]
+overheadLight : Fixture, Flashlight, RestrictedContainer ‘overhead fitting/fixture/lamp/light/socket’ ‘overhead light fixture’
bulkCapacity = 1
validContents = [brokenBulb, lightbulb]
makeLit(stat)
{
if(stat && !lightbulb.isIn(self))
failCheck('Alas, nothing happens. It needs a new bulb. ');
else
{
inherited(stat);
if(stat)
{
finishGameMsg(ftVictory, [finishOptionUndo, finishOptionFullScore]);
}
}
}
notifyInsert(obj, newCont)
{
inherited(obj, newCont);
if(obj == lightbulb && isOn)
{
"As the new bulb is put in, light immediately begins to shine. ";
makeLit(true);
}
}
;
[/code][/spoiler]
But for reasons beyond my understanding, there’s a weird glitch if I try to put the new bulb in while the light is already on. Apparently, it calls the failCheck on makeLit before putting the lightbulb in. I’ve tried over-riding this with a moveInto inside the notifyInsert method, but this results in a path-finding problem and a stack overflow:
If the light is off, both bulbs work fine. If it’s on, the dead bulb works fine. It’s only when putting the new bulb in while the light is on that trouble happens. I get my failCheck message, as mentioned, and when I look in my inventory, the character is still holding both bulbs. What is happening, and how can I fix it?
(The thought did occur to side-step the issue by making the player turn the light off, first, but that seems like a petty annoyance to inflict.)