Pertex wrote:...
<function name="ScopeVisibleLightsource" type="objectlist" parameters="lightstrength">
result = ScopeVisibleNotHeld()
result = ListCombine(result, ScopeReachableInventory()) <---add this line
lightobjects = NewObjectList()
foreach (obj, result) {
Carrot wrote:
I made it switchable and I made it a lightsource.
But it seems to be always on.
Carrot wrote:
And is there any other neater solution than modifying a core file to sort out the carrying side of things?
(GetBoolean(game.pov.parent, "dark"))(GetBoolean(player.parent, "dark"))<object name="lamp">
<inherit name="editor_object" />
<inherit name="switchable" />
<alias>lamp</alias>
<take />
<switchedondesc>It is emitting a steady, bright light.</switchedondesc>
<switchedoffdesc>It is currently off.</switchedoffdesc>
<look>A simple lamp.</look>
<onswitchon type="script">
SetObjectLightstrength (lamp, "strong")
</onswitchon>
<onswitchoff type="script">
SetObjectLightstrength (lamp, "")
</onswitchoff>
<drop type="script">
if ((GetBoolean(game.pov.parent, "dark"))) {
msg ("You don't think it wise to leave a light behind when exploring dark places")
}
else {
msg ("You drop the lamp.")
}
</drop>
</object>
<function name="ScopeVisibleLightsource" parameters="lightstrength" type="objectlist">
result = ScopeVisibleNotHeld()
result = ListCombine(result, ScopeReachableInventory())
lightobjects = NewObjectList()
foreach (obj, result) {
if (GetBoolean(obj, "lightsource") and GetString(obj, "lightstrength") = lightstrength) {
list add (lightobjects, obj)
}
}
exits = ScopeExits()
foreach (obj, exits) {
if (GetBoolean(obj, "lightsource") and GetString(obj, "lightstrength") = lightstrength) {
list add (lightobjects, obj)
}
}
return (lightobjects)
</function>
Carrot wrote:[snip]
Make a switchable, portable lightsource:
[list=1]
[*]Create a new object - we will call it lamp.[/*:m]
[*]On the [Setup] tab, give it a description (Text). e.g. A simple lamp.[/*:m]
[*]On the [Inventory] tab, mark the check-box Object can be taken[/*:m]
[*]On the [Options] tab, make it Switchable from the drop-down menu.[/*:m]
[*]Add Extra object description when switched on:, e.g. It is emitting a steady light.[/*:m]
[*]Add Extra object description when switched off:, e.g. It is currently off[/*:m]
[*][list=i][*]Under after switching on the object:, click on [Add new script][/*:m]
[*]scroll down the options to the section marked Darkness and select Set object brightness and click [Add] at the bottom of the pop-up window.[/*:m]
[*]You will now hav 4 drop-down boxes, in the 2nddrop-down, choose the object we are making a switchable lightsource - in this case lamp[/*:m]
[*]and in the 4th drop-down, choose strong[/*:m][/list:o][/*:m]
[*]Under after switching off the object:, follow the instructions above, but leave the 4th drop-down blank.[/*:m][/list:o]
Making a carried lightsource illuminate a room:
[list=1][*]In the bottom left-hand corner of the GUI, click on Filter and place a check-mark next to Show Library Elements, if one is not already present.[/*:m]
[*]In the search box above the left pane type ScopeVisibleLightsource (it is not case sensitive) and search.[/*:m]
[*]Select ScopeVisibleLightsource from the list on the left, and at the top of the GUI there should be a yellowish bar that says From library CoreScopes.aslx, follow that bar across and click [Copy] (otherwise you will not be able to edit it).[/*:m]
[*]Scroll to the bottom of the GUI and click [Add new script][/*:m]
[*]Scroll down to Variables, select Set a variable or attribute and click [Add] at the bottom of the window.[/*:m]
[*]In the box next to Set variable type result[/*:m]
[*]and in the box next to expression type ListCombine(result, ScopeReachableInventory())[/*:m]
[*]This step, I don't know if it matters or not - at the top of the script window is a tool bar, on it click the up arrow until your newly created script sits between Set variable result = ScopeVisibleNotHeld() and Set variable lightobjects = new object list[/*:m][/list:o]
Preventing the player from dropping a light source in a dark area:
[list=1]
[*]Select your object from the left hand pane, e.g. lamp[/*:m]
[*]Select the [Inventory] tab.[/*:m]
[*]Under Drop select Run script from the drop down box[/*:m]
[*]Click [Add new script] and click [If] at the top of the window.[/*:m]
[*]Make sure the drop-down at the beginning of the If statement is set to expression and in the blank box next to it type (GetBoolean(game.pov.parent, "dark"))[/*:m]
[*]Click the [Add new script] directly below the if statement you just created and above the button [Add Else If], and click [Print] at the top of the window.[/*:m]
[*]Make sure the drop-down next to Print is set to message and type a message into the box to the right, e.g. You don't think it wise to leave a light behind when exploring dark places[/*:m]
[*]Click [Add Else] then click the [Add new script] that just appeared, click [Print] and add another message, e.g. You drop the lamp.[/*:m][/list:o]
Hope this is helpful (and that I have copied the steps out correctly!
Direct thanks goes to Pertex, and jayanbonne for help specific to my queries, and other threads I have already linked to.
Pertex wrote:If you don't mind I would add your tutorial to the wiki. Could you perhaps create some screenshots of the scripts or append your game file so that I can create the images?