
<onswitchon type="script">
play sound ("flon.wav", false, false)
SetObjectLightstrength (fl1, "strong")
EnableTimer (Batteries)
SetTimerScript (Batteries) {
set (fl1, "batteries", fl1.batteries - 1)
if (fl1.batteries = 0) {
msg ("The batteries in your flashlight have run out.")
DisableTimer (Batteries)
SetObjectLightstrength (fl1, "")
SetDark (player.parent)
}
}
</onswitchon>
<onswitchoff type="script">
play sound ("floff.wav", false, false)
DisableTimer (Batteries)
SetObjectLightstrength (fl1, "")
</onswitchoff>For the second issue, can you use an item's volume? (e.g. you can set different numbers for it). Otherwise, you can have some sort of "weight" or "slots taken" attribute, where some would be 1 and some would be 2.
I think the flashlight issue is being addressed elsewhere.
Pertex wrote:I think this "setdark.." should be not necessary, but even with this command your script is working in my game.
Storyteller wrote:"Pertex"
I think this "setdark.." should be not necessary, but even with this command your script is working in my game.
How odd... So, you switch on the flashlight... after a few seconds, you get a message saying "Your flashlight has run out of batteries," and the room gets dark again?
<onswitchon type="script">
play sound ("flon.wav", false, false)
SetObjectLightstrength (fl1, "strong")
EnableTimer (Batteries)
SetTimerScript (Batteries) {
set (fl1, "batteries", fl1.batteries - 1)
if (fl1.batteries = 0) {
msg ("The batteries in your flashlight have run out.")
DisableTimer (Batteries)
SetObjectLightstrength (fl1, "")
CheckDarkness
}
}
</onswitchon>