Flashlights
Storyteller
04 Jul 2013, 06:05I've made a flashlight, and I'd like to make it so that the main room description is presented when I turn it in the inventory.
Carrot
04 Jul 2013, 08:05Storyteller wrote:I've made a flashlight, and I'd like to make it so that the main room description is presented when I turn it in the inventory.
Check my thread Portable Lightsource
Storyteller
04 Jul 2013, 08:30Carrot wrote:"Storyteller"
I've made a flashlight, and I'd like to make it so that the main room description is presented when I turn it in the inventory.
Check my thread Portable Lightsource
So, I have to go into the Code View to fix it? I can't do it from within the GUI?
Carrot
04 Jul 2013, 08:31You can do it all from the gui.
Give me a minute or 2
Give me a minute or 2
Storyteller
04 Jul 2013, 08:37Carrot wrote:You can do it all from the gui.
Give me a minute or 2
If you don't mind, go here: http://storytellersroom.chatango.com/
I made a chat room for anything related to the forum, and you don't even have to sign up. Just easier to talk.
Carrot
04 Jul 2013, 09:27Storyteller wrote:"Carrot"
You can do it all from the gui.
Give me a minute or 2
If you don't mind, go here: http://storytellersroom.chatango.com/
I made a chat room for anything related to the forum, and you don't even have to sign up. Just easier to talk.
Without being funny - I do mind.
It might be easier to "chat" but you have asked how to do this in the GUI. I am providing this (below) and others may find it useful. It will soon disappear in a Chat Room. Also, people come here to find this information, spreading to a chat-room will dilute the help and with people talking over each other in a chat-room, people could end up stringing 2 separate lumps of code together and then wonder why it doesn't work - go back to the chat-room to find the conversation has moved on.
No, I am sorry, but for this type of conversation a forum thread is more appropriate and more useable.
Also, I note you are a new user, I don't know if you need permission, but have you discussed your chat-room with the administrators of this forum?
I don't mean to offend, I am just saying.
Anyway, back on topic, here is how I did it.
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.
Storyteller
04 Jul 2013, 09:53Without being funny - I do mind.
I wasn't asking you to post the code directly into the chat, as I understand it is important to keep this as open source information for anyone and everyone to use. It is just an easier way to receive direct help, and to make sure I'm doing things correctly. Anyways, I've followed your steps exactly, but I'm not allowed to switch the flashlight, or lamp on or off within my inventory. Am I missing something? Should I just add a few scripts to the use command? Come to think of it, I guess I'll just do that.
Carrot
04 Jul 2013, 09:56what command are use using?
The default commands are
Switch/Turn on object or Switch/turn object on.
The default commands are
Switch/Turn on object or Switch/turn object on.
Storyteller
04 Jul 2013, 10:00Carrot wrote:what command are use using?
The default commands are
Switch/Turn on object or Switch/turn object on.
I am using the switch command. When the item is not in my inventory, it can be switched on and off, but as soon as I pick it up, those commands disappear.
Carrot
04 Jul 2013, 10:01Storyteller wrote:"Carrot"
what command are use using?
The default commands are
Switch/Turn on object or Switch/turn object on.
I am using the switch command. When the item is not in my inventory, it can be switched on and off, but as soon as I pick it up, those commands disappear.
Does typing the command work?
Storyteller
04 Jul 2013, 10:02Carrot wrote:
Does typing the command work?
Nope.
Carrot
04 Jul 2013, 10:04Strange, because that should do.
Try this.
On the [Object] tab, add the commands Switch on and Switch of to the Inventory verbs: pane.
Failing that, can you post your game file.
Try this.
On the [Object] tab, add the commands Switch on and Switch of to the Inventory verbs: pane.
Failing that, can you post your game file.
Storyteller
04 Jul 2013, 10:10Carrot wrote:On the [Object] tab, add the commands Switch on and Switch of to the Inventory verbs: pane.
Failing that, can you post your game file.
They're already on there.
<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Shelter">
<gameid>f0cc23b4-03a6-4ba0-b607-36cb59bfea9a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<cover>hand.png</cover>
<subtitle>Survive The Zombie Apocalypse</subtitle>
<author>The Storyteller</author>
<description>Zombies have taken over the world! You knew this would happen some day.</description>
<attr name="autodescription_youarein_useprefix" type="boolean">false</attr>
<category>Horror</category>
<difficulty>Hard</difficulty>
<cruelty>Cruel</cruelty>
<showhealth type="boolean">false</showhealth>
<povstatusattributes type="stringdictionary" />
<showcommandbar />
<backgroundimage type="string"></backgroundimage>
<pov type="object">player</pov>
<start type="script">
</start>
<autodescription type="boolean">false</autodescription>
<defaultlinkforeground>Red</defaultlinkforeground>
<appendobjectdescription type="boolean">false</appendobjectdescription>
<defaultbackground>Black</defaultbackground>
<defaultforeground>White</defaultforeground>
</game>
<object name="start">
<inherit name="editor_room" />
<descprefix>You are in</descprefix>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix type="string"></prefix>
<dark />
<darkroomdescription><![CDATA[Your eyelids roll back, and you sit up. You can barely make out the room around you.<br/><br/>As your eyes adjust, you notice the silhouette of the light switch, next to the door across from your bed. The moonlight shining in through your window also illuminates your desk against the far wall.]]></darkroomdescription>
<description>You look around your bedroom... the clock on your wall is frozen at 2:13AM. It's not raining outside, and it isn't particularly windy either. What happened to the power? Maybe you should go find out?</description>
<alias>your bedroom</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<Health type="int">100</Health>
<alias>me</alias>
<maxobjects type="int">0</maxobjects>
<look type="script">
</look>
<attr name="pov_look" type="script"><![CDATA[
if (player.Health = 100) {
msg ("You give yourself a once-over, checking for cuts and bruises. Not a scratch on you.")
}
else if (player.Health < 100 and player.Health >= 90) {
msg ("You check yourself, noticing a few scratches. Nothing serious.")
}
else if (player.Health < 90 and player.Health >= 80) {
msg ("You look yourself over... nothing extremely serious, but you should probably apply some bandages.")
}
else if (player.Health < 80 and player.Health >= 70) {
msg ("You look down at yourself... you've got some bruising and cuts. You're definintely going to need some bandages.")
}
else if (player.Health < 70 and player.Health >= 60) {
msg ("Your condition isn't exactly satisfactory, and you're going to need something to stop bleeding from some open wounds on your body.")
}
else if (player.Health < 60 and player.Health >= 50) {
msg ("You've begun limping slightly... your body is extremely bruised, and you have several open cuts across your body.")
}
else if (player.Health < 50 and player.Health >= 40) {
msg ("You have a very obvious limp, and you are losing blood... you need to find medicine before your condition worsens.")
}
else if (player.Health < 40 and player.Health >= 30) {
msg ("You're not sure how you're still walking... you've got obvious wounds along your tattered frame, and you're losing blood quickly.")
}
else if (player.Health < 30 and player.Health >= 20) {
msg ("You're starting to feel very queasy, and you're struggling to keep moving.")
}
else if (player.Health < 20 and player.Health >= 10) {
msg ("As you lean over to check yourself, you become extremely dizzy, nearly toppling over. You take several seconds to recompose yourself. You need serious medical attention.")
}
else if (player.Health < 10 and player.Health >= 5) {
msg ("Death is near... you are in agony, and you're having serious trouble even keeping your eyes open.")
}
else if (player.Health < 5 and player.Health >= 1) {
msg ("You're basically crawling... you've lost most of your blood, and you are quite sure you will die very soon... you think of your family and friends, wishing you'd never gotten out of bed.")
}
]]></attr>
<take type="boolean">false</take>
</object>
<object name="lsr1">
<inherit name="editor_object" />
<inherit name="switchable" />
<alias>Light Switch</alias>
<look>It's a lightswitch... it turns lights on and off.</look>
<drop type="boolean">false</drop>
<use type="boolean">false</use>
<switchedon type="boolean">false</switchedon>
<lightsource />
<lightstrength>weak</lightstrength>
<takemsg>You can't take that off the wall without some serious tools.</takemsg>
<switchonmsg>You flick the switch into the on position, but surprisingly, nothing happens.</switchonmsg>
<switchoffmsg>You switch it back into the off position, still no light.</switchoffmsg>
<useon type="scriptdictionary">
<item key="fl1">
msg ("You hit the light switch with the flashlight... it doesn't make the lights work.")
</item>
</useon>
<askdefault type="script">
msg ("The light switch just stares at you.")
</askdefault>
<telldefault type="script">
msg ("The light switch doesn't respond. What were you expecting?")
</telldefault>
</object>
<object name="dr1">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>Desk</alias>
<openscript type="script">
HelperOpenObject (dr1)
msg ("You sift through the drawers... you see something dark in the corner of one of them... a flashlight?")
MakeObjectVisible (fl1)
SetObjectLightstrength (fl1, "weak")
</openscript>
<lightsource />
<lightstrength>weak</lightstrength>
<takemsg>The desk is pretty heavy... You can't pick it up.</takemsg>
<closescript type="script">
msg ("You close the drawers.")
HelperCloseObject (dr1)
</closescript>
<look>It's a desk. It's got two drawers on either side, with papers and books sitting on top of it.</look>
<ask type="scriptdictionary" />
<askdefault type="script">
msg ("The desk sits silently... it ponders your question for a moment, before...... doing nothing. Shocker.")
</askdefault>
<telldefault type="script">
msg ("The desk doesn't isn't in the mood to talk.")
</telldefault>
<useon type="scriptdictionary">
<item key="fl1">
msg ("You hit the desk with the flashlight...")
</item>
</useon>
</object>
<object name="fl1">
<inherit name="editor_object" />
<inherit name="switchable" />
<alias>Flashlight</alias>
<listalias>Flashlight</listalias>
<take />
<visible type="boolean">false</visible>
<look>A flashlight! This'll help you get around in the dark.</look>
<takemsg>You pick up the flashlight. You can hear the quiet rattle of batteries; good.</takemsg>
<use type="script">
if (not IsSwitchedOn(fl1)) {
SwitchOn (fl1)
}
else if (IsSwitchedOn(fl1)) {
SwitchOff (fl1)
}
</use>
<dropmsg>You should probably keep the flashlight.</dropmsg>
<drop type="boolean">false</drop>
<onswitchon type="script">
SetObjectLightstrength (fl1, "strong")
</onswitchon>
<onswitchoff type="script">
</onswitchoff>
<lightsource />
<askdefault type="script">
msg ("Your flashlight doesn't respond.")
</askdefault>
<telldefault type="script">
msg ("Your flashlight doesn't seem to care about what you're saying.")
</telldefault>
<switchonmsg>You click the button on the side of the flashlight, turning it on.</switchonmsg>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
</inventoryverbs>
<switchoffmsg>You click the button again, turning the flashlight off.</switchoffmsg>
</object>
<object name="clock1">
<inherit name="editor_object" />
<alias>Clock</alias>
</object>
<object name="sc1">
<inherit name="editor_object" />
<alias>Soda Can</alias>
<visible />
<take type="boolean">false</take>
</object>
</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>
</asl>
Carrot
04 Jul 2013, 10:25Storyteller wrote:"Carrot"
On the [Object] tab, add the commands Switch on and Switch of to the Inventory verbs: pane.
Failing that, can you post your game file.
They're already on there.<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Shelter">
<gameid>f0cc23b4-03a6-4ba0-b607-36cb59bfea9a</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<cover>hand.png</cover>
<subtitle>Survive The Zombie Apocalypse</subtitle>
<author>The Storyteller</author>
<description>Zombies have taken over the world! You knew this would happen some day.</description>
<attr name="autodescription_youarein_useprefix" type="boolean">false</attr>
<category>Horror</category>
<difficulty>Hard</difficulty>
<cruelty>Cruel</cruelty>
<showhealth type="boolean">false</showhealth>
<povstatusattributes type="stringdictionary" />
<showcommandbar />
<backgroundimage type="string"></backgroundimage>
<pov type="object">player</pov>
<start type="script">
</start>
<autodescription type="boolean">false</autodescription>
<defaultlinkforeground>Red</defaultlinkforeground>
<appendobjectdescription type="boolean">false</appendobjectdescription>
<defaultbackground>Black</defaultbackground>
<defaultforeground>White</defaultforeground>
</game>
<object name="start">
<inherit name="editor_room" />
<descprefix>You are in</descprefix>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix type="string"></prefix>
<dark />
<darkroomdescription><![CDATA[Your eyelids roll back, and you sit up. You can barely make out the room around you.<br/><br/>As your eyes adjust, you notice the silhouette of the light switch, next to the door across from your bed. The moonlight shining in through your window also illuminates your desk against the far wall.]]></darkroomdescription>
<description>You look around your bedroom... the clock on your wall is frozen at 2:13AM. It's not raining outside, and it isn't particularly windy either. What happened to the power? Maybe you should go find out?</description>
<alias>your bedroom</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<Health type="int">100</Health>
<alias>me</alias>
<maxobjects type="int">0</maxobjects>
<look type="script">
</look>
<attr name="pov_look" type="script"><![CDATA[
if (player.Health = 100) {
msg ("You give yourself a once-over, checking for cuts and bruises. Not a scratch on you.")
}
else if (player.Health < 100 and player.Health >= 90) {
msg ("You check yourself, noticing a few scratches. Nothing serious.")
}
else if (player.Health < 90 and player.Health >= 80) {
msg ("You look yourself over... nothing extremely serious, but you should probably apply some bandages.")
}
else if (player.Health < 80 and player.Health >= 70) {
msg ("You look down at yourself... you've got some bruising and cuts. You're definintely going to need some bandages.")
}
else if (player.Health < 70 and player.Health >= 60) {
msg ("Your condition isn't exactly satisfactory, and you're going to need something to stop bleeding from some open wounds on your body.")
}
else if (player.Health < 60 and player.Health >= 50) {
msg ("You've begun limping slightly... your body is extremely bruised, and you have several open cuts across your body.")
}
else if (player.Health < 50 and player.Health >= 40) {
msg ("You have a very obvious limp, and you are losing blood... you need to find medicine before your condition worsens.")
}
else if (player.Health < 40 and player.Health >= 30) {
msg ("You're not sure how you're still walking... you've got obvious wounds along your tattered frame, and you're losing blood quickly.")
}
else if (player.Health < 30 and player.Health >= 20) {
msg ("You're starting to feel very queasy, and you're struggling to keep moving.")
}
else if (player.Health < 20 and player.Health >= 10) {
msg ("As you lean over to check yourself, you become extremely dizzy, nearly toppling over. You take several seconds to recompose yourself. You need serious medical attention.")
}
else if (player.Health < 10 and player.Health >= 5) {
msg ("Death is near... you are in agony, and you're having serious trouble even keeping your eyes open.")
}
else if (player.Health < 5 and player.Health >= 1) {
msg ("You're basically crawling... you've lost most of your blood, and you are quite sure you will die very soon... you think of your family and friends, wishing you'd never gotten out of bed.")
}
]]></attr>
<take type="boolean">false</take>
</object>
<object name="lsr1">
<inherit name="editor_object" />
<inherit name="switchable" />
<alias>Light Switch</alias>
<look>It's a lightswitch... it turns lights on and off.</look>
<drop type="boolean">false</drop>
<use type="boolean">false</use>
<switchedon type="boolean">false</switchedon>
<lightsource />
<lightstrength>weak</lightstrength>
<takemsg>You can't take that off the wall without some serious tools.</takemsg>
<switchonmsg>You flick the switch into the on position, but surprisingly, nothing happens.</switchonmsg>
<switchoffmsg>You switch it back into the off position, still no light.</switchoffmsg>
<useon type="scriptdictionary">
<item key="fl1">
msg ("You hit the light switch with the flashlight... it doesn't make the lights work.")
</item>
</useon>
<askdefault type="script">
msg ("The light switch just stares at you.")
</askdefault>
<telldefault type="script">
msg ("The light switch doesn't respond. What were you expecting?")
</telldefault>
</object>
<object name="dr1">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>Desk</alias>
<openscript type="script">
HelperOpenObject (dr1)
msg ("You sift through the drawers... you see something dark in the corner of one of them... a flashlight?")
MakeObjectVisible (fl1)
SetObjectLightstrength (fl1, "weak")
</openscript>
<lightsource />
<lightstrength>weak</lightstrength>
<takemsg>The desk is pretty heavy... You can't pick it up.</takemsg>
<closescript type="script">
msg ("You close the drawers.")
HelperCloseObject (dr1)
</closescript>
<look>It's a desk. It's got two drawers on either side, with papers and books sitting on top of it.</look>
<ask type="scriptdictionary" />
<askdefault type="script">
msg ("The desk sits silently... it ponders your question for a moment, before...... doing nothing. Shocker.")
</askdefault>
<telldefault type="script">
msg ("The desk doesn't isn't in the mood to talk.")
</telldefault>
<useon type="scriptdictionary">
<item key="fl1">
msg ("You hit the desk with the flashlight...")
</item>
</useon>
</object>
<object name="fl1">
<inherit name="editor_object" />
<inherit name="switchable" />
<alias>Flashlight</alias>
<listalias>Flashlight</listalias>
<take />
<visible type="boolean">false</visible>
<look>A flashlight! This'll help you get around in the dark.</look>
<takemsg>You pick up the flashlight. You can hear the quiet rattle of batteries; good.</takemsg>
<use type="script">
if (not IsSwitchedOn(fl1)) {
SwitchOn (fl1)
}
else if (IsSwitchedOn(fl1)) {
SwitchOff (fl1)
}
</use>
<dropmsg>You should probably keep the flashlight.</dropmsg>
<drop type="boolean">false</drop>
<onswitchon type="script">
SetObjectLightstrength (fl1, "strong")
</onswitchon>
<onswitchoff type="script">
</onswitchoff>
<lightsource />
<askdefault type="script">
msg ("Your flashlight doesn't respond.")
</askdefault>
<telldefault type="script">
msg ("Your flashlight doesn't seem to care about what you're saying.")
</telldefault>
<switchonmsg>You click the button on the side of the flashlight, turning it on.</switchonmsg>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
</inventoryverbs>
<switchoffmsg>You click the button again, turning the flashlight off.</switchoffmsg>
</object>
<object name="clock1">
<inherit name="editor_object" />
<alias>Clock</alias>
</object>
<object name="sc1">
<inherit name="editor_object" />
<alias>Soda Can</alias>
<visible />
<take type="boolean">false</take>
</object>
</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>
</asl>
OK, I copied that into a text editor and saved it as an .aslx file and ran it.
I didn't do anything to the code. i found the flashlight, I typed turn on flashlight and it works, the clock and the soda can became visible.
By the way, the turn on and turn off commands are only listed in the display verbs scroll down to inventory verbs and add them there, and then the options will appear when you click on the links in the text or in the right pane.
[edit]
I have done it for you
Here is your original file:
Here is the amended file: (I have only added the Inventory verbs, nothing else)