I would make the flashlight an object the player can pick up and turn on and off. here is a quick example game.
<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testy">
<gameid>ac0b3225-36cd-43ab-b1fc-eb4cdc4af74e</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<start type="script">
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="changedheight_rating" type="script">
player.height = GetHeight()
</attr>
</object>
<exit alias="south" to="second_room">
<inherit name="southdirection" />
</exit>
<object name="flashlight">
<inherit name="editor_object" />
<inherit name="switchable" />
<feature_switchable />
<take />
<battery type="int">23</battery>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Take</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Drop</value>
</inventoryverbs>
<look>An ordinary flashlight{if flashlight.switchedon:shining brightly}.</look>
<turnon type="script"><![CDATA[
if (ListContains(ScopeReachable(), this)) {
if (this.switchedon) {
msg (DynamicTemplate("AlreadySwitchedOn", this))
}
if (this.battery < 1) {
msg ("You try to turn on the flashlight, but the battery is dead.")
}
else {
msg ("You turn on the flashlight.")
do (this, "turn_on")
}
}
else {
msg (DynamicTemplate("DefaultTurnOn", this))
}
]]></turnon>
<turnoff type="script">
if (ListContains(ScopeReachable(), this)) {
if (not this.switchedon) {
msg (DynamicTemplate("AlreadySwitchedOff", this))
}
else {
msg ("You turn off the flashlight.")
do (this, "turn_off")
}
}
else {
msg (DynamicTemplate("DefaultTurnOff", this))
}
</turnoff>
<attr name="turn_on" type="script">
this.switchedon = true
EnableTurnScript (flashlight_turnscript)
msg (flashlight_turnscript.enabled)
SetObjectLightstrength (this, "strong")
</attr>
<attr name="turn_off" type="script">
DisableTurnScript (flashlight_turnscript)
this.switchedon = false
SetObjectLightstrength (this, "")
</attr>
</object>
<object name="plasticbox">
<inherit name="editor_object" />
<inherit name="container_open" />
<take />
<feature_container />
<transparent />
</object>
<object name="woodenbox">
<inherit name="editor_object" />
<inherit name="container_open" />
<take />
<feature_container />
</object>
</object>
<object name="second_room">
<inherit name="editor_room" />
<feature_lightdark />
<dark />
<description>An ornate room devoid of lights.</description>
<exit alias="north" to="room">
<inherit name="northdirection" />
<lightsource />
<lightstrength>weak</lightstrength>
</exit>
<object name="teapot">
<inherit name="editor_object" />
</object>
<exit alias="east">
<inherit name="eastdirection" />
</exit>
</object>
<turnscript name="flashlight_turnscript">
<enabled type="boolean">false</enabled>
<script>
flashlight.battery = flashlight.battery - 1
if (flashlight.battery = 10 and ListContains(ScopeReachable(), flashlight)) {
msg ("Your flashlight starts to flicker.")
}
if (flashlight.battery = 0) {
if (ListContains(ScopeReachable(), flashlight)) {
msg ("Your flashlight flickers and dies.")
}
do (flashlight, "turn_off")
}
</script>
</turnscript>
<walkthrough name="test">
<steps type="simplestringlist">
take flashlight
x flashlight
take plasticbox
take woodenbox
south
x flashlight
turn on flashlight
x flashlight
l
drop flashlight
l
turn on flashlight
put flashlight in woodenbox
take flashlight
put flashlight in woodenbox
l
close woodenbox
l
open woodenbox
put flashlight in plasticbox
l
close plasticbox
l
turn off flashlight
open plasticbox
turn off flashlight
l
turn on flashlight
l
look at flashlight
z
look at flashlight
turn on flashlight
</steps>
</walkthrough>
</asl>
There is an issue here about what happens if the player goes into a dark room without a torch. She can easily be trapped there as the exits are not accessible if they cannot be seen. One way around that is to have exits lit, but be aware of the issue