I have a room, and the description of the room states that it's dark. I have a light switch object that can turn on or off. Whether it's on or off though, when look at room, it states it's dark. How can i change the look at room description depending on whether the light is on or off? Please help!
The lightswitch system uses a couple of attributes, but mainly you are looking for a couple things for this.
If the room is set to be dark, it will have an attribute called "dark". the "room is initially dark" toggle sets the attribute to "True".
this is where the messy, codey stuff comes in. :)
switching the lightswitch off will be the same thing, but setting the attribute to True.
turning the Dark to False will switch it to show the room description instead of the dark room description.
Be aware, the GUI gets VERY twitch about capitalization. you WILL have to capitalize the first letter of True and False, or it is very likely to get confused.
There are a few other ways to do this, but that's the simplest that I've cooked up. The Switch On and Off verbs that are created automatically should take care of checking to see if the switch is on or not already.
I have several ways of creating light/dark rooms and each kind of serve a different purpose.
In my tutorial, I have these brief explanations to help users understand how they work. The first explanation of the room is this:
"So, I cheat a bit here. I have the switch, which will obviously turn on the lights. If you create object switch and tick the switchable option under features, you will have an option to run a script when object is turned on. In this script, I add a message to tell the player the light switch is flipped and I also make each object in the room visible. Then, in the turn off script I just do the opposite."
This is an excellent way to utilize light/dark rooms and still have other options available. Like seeing a light switch or seeing traces of things in the dark or for SEEING exits!
Another explanation is this:
"Not much to this.
The player is starting inside a cardboard box and must get out to continue.
Exits in this case are no different than objects!"
This is good if you want to sort of trap a player in a room, but give hints within the dark room for them to solve certain puzzles to either get out of the room or to light the room up.
As far as I know, this is a tricky bit for the player and can be a bit unnerving for the player. It's VERY easy for the game creator though. Here is the explanation for that room:
"To use the built-in feature for light and dark rooms, you must have the "lightness and Darkness..." box ticked on the games tab.
If the player wanders into a dark room without a light source, everything is made invisible except the room description. This can be a killer if left as is. Nothing is visible, even exits. In one of my games I have several dark rooms, but I combine them with a 'before entering room script'. In this script, I have an 'If' script that checks to see if the player has an illumination source in their inventory. If not, I script the player to immediately move out of the room (or not allow them to enter the room to begin with), and then I return them back to the lit room from whence they came.
There are lots of ways to handle this, but the different options certainly work better for different scenarios.
Let me know if you have questions. Good luck!
You can also add some cool ambience by setting attributes. For example...
Lamp Object
Attribute
flag: boolean
When lamp is switched on, lamp.flag=True.
When lamp is switched off, lamp.flag=False.
Then in your text you can say...
{if lamp.flag=True:The light was shining brightly in the room.}{if lamp.flag=False:The room was dark with no signs of light.}
Just thought I would throw that in there!
Gah, yes, I forgot about not being able to see the exits unless they're a weak lightsource by themselves. XD
Yesterday just makes me feel smarter and smarter.
headdesk
the joys of programming... programmers like frustration... and being bald (from pulling our hair out)... and having a big red/black/purple bruise from hitting our heads on the desk... the joys of programming... troubleshooting... like more than 50% of programming... is just trouble shooting... lol.