OK! It is still missing the cannotPutInMsg bit but it should look better now
power_plant_generator_battery_holder: OpenableContainer, SingleContainer, RestrictedContainer, Hidden, Fixture
vocabWords = '(battery) (generator) holder/receptacle/snap/enclosure* holders receptacles snaps enclosures'
name = 'battery holder'
location = Power_plant
initiallyOpen = true
validContents = [nuclear_Battery]
desc()
{
if(nuclear_Battery.isIn(self))
{
"The battery rests inside. ";
}
else
{
"The battery holder is open and empty. These generators are plug and play, inserting the right battery on it should power it on. ";
}
}
notifyInsert(obj, newCont)
{
if(obj == nuclear_Battery)
{
"When I insert the nuclear battery in the holder I hear a click and the compartment closes. ";
self.makeOpen(nil);
un_nuclear_Battery.makePresent();
} else inherited (obj, newCont);
}
dobjFor(Open)
{
check()
{
if(nuclear_Battery.isIn(self))
{
failCheck('The generator is already on, I better don\'t mess with the battery holder anymore. ');
} else inherited;
}
}
dobjFor(Close)
{
check()
{
if(!nuclear_Battery.isIn(self))
{
failCheck('I should not attempt to close it when there is no battery inside. ');
} else inherited;
}
}
;
and I defined the unBattery as:
un_nuclear_Battery: PresentLater, Unthing //Nuclear battery
vocabWords = '(nuclear) (atomic) battery*batteries'
name = 'nuclear battery'
location = Power_plant
notHereMsg = 'The battery is locked inside the generator, I don\´t need to mess with it anymore. '
;
Everything seems to work well! I need also to take care of make the command âinsert battery in generatorâ the same as âinsert battery in holderâ once the holder has been discovered, but that can wait a bit :).