As of Version 5.4.1 you still can't light up a room by carrying a lamp, you have to drop it on the floor first. (?)
If you have a need for a portable light-source in your inventory that lights up any room you visit, then do this:
Enable the core libraries in the object list on the left. (bottom left corner, click 'Filter' and enable 'Show Library Elements'
Right click on the Function list header and select 'Add Function', call it 'ScopeInventoryLightsources'.
Paste this in:
result = ScopeInventory()
lightobjects = NewObjectList()
foreach (obj, result) {
if (GetBoolean(obj, "lightsource") and GetString(obj, "lightstrength") = "strong") {
list add (lightobjects, obj)
}
}
return (lightobjects)
At the top set the Return Type to 'Object List'
Then find the existing function 'CheckDarkness', make a copy, and insert text as shown here:
First section of original code:
roomCheckDarkness = true
if (GetBoolean(game.pov.parent, "dark")) {
if (ListCount(ScopeVisibleLightsource("strong")) > 0) {
roomCheckDarkness = false
}
New code to insert:
if (ListCount(ScopeInventoryLightsources()) > 0) {
roomCheckDarkness = false
}
Last section of original code:
}
game.pov.parent.darklevel = roomCheckDarkness
return (roomCheckDarkness)
Now when the flashlight object is in your inventory and switched on, it will light up any room you visit. As expected, the flashlight still won't light up the room if you have it contained inside something else in your inventory, unless that something else is a transparent container. All pretty cool!
------------------------------------------------------------------------------------------------------------------------------------
Here are some more trivial scripts to help make that flashlight more practical, I offer two different approaches:
First style: Pros: Will light up a room whether held in inventory or dropped on the floor.
Cons: If 'switched off' in a dark room and dropped, you will not be able to see it or pick it back up, possibly leaving you stuck in a dark room.
Second style: Pros: Will light up a room whether held in inventory or dropped on the floor.
Cons: If 'switched off' in a dark room, you can still see it either in your inventory or dropped on the floor. If you want your switched-off flashlight to NOT be visible on the floor of a dark room, you must use the First style above.
I offer both styles with a command that reprints the room description again in case you want to describe the room after the light level changes. If you don't like it, just delete the 'ShowRoomDescription' command.
(paste these in while it's in code-view)
First-style code:Put this chunk in the flashlight's 'After Switching On the Object' script:
flashlight.lightstrength = "strong"
flashlight.lightsource = True
ShowRoomDescription
Put this chunk in the flashlight's 'After Switching Off the Object' script:
flashlight.lightsource = False
ShowRoomDescription
Second-style code:Put this chunk in the flashlight's 'After Switching On the Object' script:
flashlight.lightstrength = "strong"
flashlight.lightsource = True
ShowRoomDescription
Put this chunk in the flashlight's 'After Switching Off the Object' script:
flashlight.lightstrength = "weak"
flashlight.lightsource = True
ShowRoomDescription
Hope this helps others. I spent several days coding spaghetti before I figured out how the Quest execution is structured.
If any gurus out there see a big loophole or think this creates problems elsewhere, by all means shout out.
good luck