Working on my first game, I'm having some trouble with light
Hippeus
17 Feb 2013, 12:04I'm working on my first game using Quest, and I'm running into a problem that has snagged my time for several hours. I'm very inexperienced with coding, the most I've understood it is using Quest's scripting system.
I'm making a game for some people that have never played a Text Adventure game before, so I'm trying to introduce concepts one by one.
Right now, I'm trying to introduce the concept of interacting with the environment, which involves turning on a lightbulb to light a room around 1 am. As I understood it, I just needed to make the room dark, mark the lightbulb as a light source, and then switch/turn it on. That was mistaken, apparently, so I made a script. After the lightbulb is switched on, it will light the room (which is a Kitchen). After testing a couple of things, I've found two things to be true.
1.) The lightbulb, for whatever reason, is not actually switching on when I tell it to switch on, but it is receiving the command (I had it place some text whenever it was used). I also noticed that it was not placing the text I told it too when it was switched on, so I believing the lightbulb is not switching on. This is an entirely different issue that I really would like help with.
2.) The room is not dark. No matter what I do, I cannot make the room dark for some reason. If I check the box for it, it remains lit. If I set up a script to make the room dark, it is not dark. I know it isn't being made dark because the text I checked to display when the room is dark is not showing up, the normal room description is. I have absolutely no idea what my problem is there, and I really need some help from somebody who knows what they are doing.
I'm using Quest online, in Google Chrome, if that helps at all.
I'm making a game for some people that have never played a Text Adventure game before, so I'm trying to introduce concepts one by one.
Right now, I'm trying to introduce the concept of interacting with the environment, which involves turning on a lightbulb to light a room around 1 am. As I understood it, I just needed to make the room dark, mark the lightbulb as a light source, and then switch/turn it on. That was mistaken, apparently, so I made a script. After the lightbulb is switched on, it will light the room (which is a Kitchen). After testing a couple of things, I've found two things to be true.
1.) The lightbulb, for whatever reason, is not actually switching on when I tell it to switch on, but it is receiving the command (I had it place some text whenever it was used). I also noticed that it was not placing the text I told it too when it was switched on, so I believing the lightbulb is not switching on. This is an entirely different issue that I really would like help with.
2.) The room is not dark. No matter what I do, I cannot make the room dark for some reason. If I check the box for it, it remains lit. If I set up a script to make the room dark, it is not dark. I know it isn't being made dark because the text I checked to display when the room is dark is not showing up, the normal room description is. I have absolutely no idea what my problem is there, and I really need some help from somebody who knows what they are doing.
I'm using Quest online, in Google Chrome, if that helps at all.

Pertex
17 Feb 2013, 14:45It's difficult to say something about your problem not seeing what you are doing. I think you added an object named lightbulb, activated "can be switched on/off" and added a script "after switching on the object", where you set the brightness off the lightbulb?
TriangleGames
17 Feb 2013, 15:15Pertex wrote:... added a script "after switching on the object", where you set the brightness of the lightbulb?
I think this is where you're problem is, if I understand what you've said.
1. Switching an object on/off doesn't do anything in and of itself except change the code attribute for the object between "on" and "off," because that kind of a switch could have many different effects with different objects. In order for it to do something different when it's on, you have to include that specifically.
2. Making something a lightsource does not automatically create ANY link to the concept of it being on or off, and if you set something to be a lightsource in its starting options, it will already be lit when the game starts.
3. What you need to do is let the lightbulb not be a strong lightsource when the game starts, and instead include a script which runs when it is switched to on that makes it a strong lightsource. You're looking for "set object brightness," as Pertex said.
4. Now this is important: notice the difference between a "weak" lightsource and a "strong" light source. In order for the player to be able to see the lightbulb itself when the room is dark, it will need to start out as a "weak" lightsource. That allows it to be seen in the dark, but won't illuminate the whole room, like a strong lightsource will.
Did I understand the problem right? By the way, people really enjoy a little access to your game, or even screenshots of your problem, which I believe is the most you can offer while using the WebEditor. It's just easier to understand the problem if they can look at it themselves. (I say "they" because I am actually NOT one of the experts here, I've just done a LOT of work with lightsources recently.)
Hippeus
18 Feb 2013, 02:59I've applied some of your advice and now I have some screenshots to show you.
I made the Lightbulb a lightsource set to weak, which solved my lighting problem. The room is now properly set to be dark, and displays the proper text.
My new problem is definitely an advancement, and I think it comes from me not understanding verbs.
Here's what I have for verbs on the Lightbulb.

Adding anything saying turn off or switch off would tell me the verb already exists.
Here is what I have set under the "Options menu"

It's offscreen, but it IS set to be a switchable object (can be switched on/off)
Lastly, this is what happens if I load up the game and tell it to switch the lightbulb on or off.

Previously, the object just would not respond to being switched on, the text it was supposed to display never displayed. I'm definitely doing something wrong.
I made the Lightbulb a lightsource set to weak, which solved my lighting problem. The room is now properly set to be dark, and displays the proper text.
My new problem is definitely an advancement, and I think it comes from me not understanding verbs.
Here's what I have for verbs on the Lightbulb.

Adding anything saying turn off or switch off would tell me the verb already exists.
Here is what I have set under the "Options menu"

It's offscreen, but it IS set to be a switchable object (can be switched on/off)
Lastly, this is what happens if I load up the game and tell it to switch the lightbulb on or off.

Previously, the object just would not respond to being switched on, the text it was supposed to display never displayed. I'm definitely doing something wrong.
TriangleGames
18 Feb 2013, 03:40It looks to me like everything is set up fine EXCEPT that you don't need the verb for "switch on" added under the verbs tab separately, because it adds both the on and off switch verbs automatically when you select "can be switched on/off." It shouldn't allow you to add either one once that is set under options.
After a little experimenting, I'm guessing what you did was add the "switch on" verb first and then selected "can be switched" afterward. That would explain why it let you add the "switch on" verb, but not the "switch off" verb. Try deleting the "switch on" verb under the verbs tab. You might also want to reset the "can be switched" setting to clear things out by just changing it to "cannot switch" and then back to "can switch." But you should delete the added verb under the verbs tab first.
One other thing to make note of is that the game does not reprint the room description automatically when the light is turned on.
So, to check that the room has been properly changed, you'll want to type in just "look" to reprint the room display, which should have changed. I've been a little annoyed by that, but I haven't looked into how to resolve it yet. I think I'll go look into it now though, so I'll get back to you if I figure it out before anyone else chime's in here.
EDIT: Okay, I got the room description to re-display after lights go on/off. As long as the description text for the room is plain text (i.e. not a script), it's pretty easy.
In the script list for "switch on," right under where you have "set object brightness," you put in the script "print: expression" and in the expression box you just put
kitchen.description
Likewise, in the "switch off" script list, you do the same but it needs to say
kitchen.darkroomdescription
That will make the default/dark room descriptions print appropriately after the lights are switched on/off without the player having to type "look" again to get the new room description. But, remember that only works if the descriptions you're referencing are plain text. If the room description itself is a script (which it is in my game), it will actually print to screen something like
"Script: if {cart wreck.dark = true, print: "yadda, yadda, yadda"
So if the room description is a script, something a little more involved will be needed, but I'm not sure what yet.
Re-Edit: I suppose you could just COPY the text you want displayed, and print it as ordinary text, instead of referencing the room's description attributes... that might even be easier actually, but it feels less "professional" for some reason...
After a little experimenting, I'm guessing what you did was add the "switch on" verb first and then selected "can be switched" afterward. That would explain why it let you add the "switch on" verb, but not the "switch off" verb. Try deleting the "switch on" verb under the verbs tab. You might also want to reset the "can be switched" setting to clear things out by just changing it to "cannot switch" and then back to "can switch." But you should delete the added verb under the verbs tab first.
One other thing to make note of is that the game does not reprint the room description automatically when the light is turned on.
So, to check that the room has been properly changed, you'll want to type in just "look" to reprint the room display, which should have changed. I've been a little annoyed by that, but I haven't looked into how to resolve it yet. I think I'll go look into it now though, so I'll get back to you if I figure it out before anyone else chime's in here.
EDIT: Okay, I got the room description to re-display after lights go on/off. As long as the description text for the room is plain text (i.e. not a script), it's pretty easy.
In the script list for "switch on," right under where you have "set object brightness," you put in the script "print: expression" and in the expression box you just put
kitchen.description
Likewise, in the "switch off" script list, you do the same but it needs to say
kitchen.darkroomdescription
That will make the default/dark room descriptions print appropriately after the lights are switched on/off without the player having to type "look" again to get the new room description. But, remember that only works if the descriptions you're referencing are plain text. If the room description itself is a script (which it is in my game), it will actually print to screen something like
"Script: if {cart wreck.dark = true, print: "yadda, yadda, yadda"
So if the room description is a script, something a little more involved will be needed, but I'm not sure what yet.
Re-Edit: I suppose you could just COPY the text you want displayed, and print it as ordinary text, instead of referencing the room's description attributes... that might even be easier actually, but it feels less "professional" for some reason...
Hippeus
18 Feb 2013, 10:52Phenomenal job, all of this is incredibly helpful to me.
I solved my issues, the room is now properly dark, the lightbulb does change that, propers text is displayed, etc.
Except for trying your solution to the default room description not displaying. I get this error:
Error running script: SyntaxError: Unexpected token "Home___SPACE___Kitchen___DOT___description" <IDENTIFIER>; expected one of <EOF>Line: 1, Column: 3
Here is the print: expression thing I put in.

(Home Kitchen is the room name I have)
I can't make sense of that, I don't know what <EOF> is supposed to mean.
As for the less professional thing, I get that feeling too. I could very easily make this all smoke and mirrors, but making something that genuinely receives player input is a satisfying feeling from a developer standpoint. I don't want to make this all smoke and mirrors. Not to mention, I'm getting some actual experience in.
I really do appreciate all of your help so far, it's been far more frequent than I assumed it would be, and you seemed to put in a good amount of effort uncovering my mistakes.
I solved my issues, the room is now properly dark, the lightbulb does change that, propers text is displayed, etc.
Except for trying your solution to the default room description not displaying. I get this error:
Error running script: SyntaxError: Unexpected token "Home___SPACE___Kitchen___DOT___description" <IDENTIFIER>; expected one of <EOF>Line: 1, Column: 3
Here is the print: expression thing I put in.

(Home Kitchen is the room name I have)
I can't make sense of that, I don't know what <EOF> is supposed to mean.
As for the less professional thing, I get that feeling too. I could very easily make this all smoke and mirrors, but making something that genuinely receives player input is a satisfying feeling from a developer standpoint. I don't want to make this all smoke and mirrors. Not to mention, I'm getting some actual experience in.
I really do appreciate all of your help so far, it's been far more frequent than I assumed it would be, and you seemed to put in a good amount of effort uncovering my mistakes.

Pertex
18 Feb 2013, 11:32Try this:


Hippeus
18 Feb 2013, 19:33That's a very stupid mistake on my part, everything is fully functional. Thanks a ton!
TriangleGames
25 Feb 2013, 16:22I just figured out how to do something related to this. Printing the room description only prints the literal description text for the room, but I want the ENTIRE room display to re-appear after significant changes, including the lists of objects and exits that, for instance, could not be seen until the lights were turned on. Turns out it's really simple!
All you need to do is call the function "OnEnterRoom" and add "null" as the parameter. Voila, when the lights come on, all the newly visible objects are automatically shown to the player, just as if they'd entered the room again.
All you need to do is call the function "OnEnterRoom" and add "null" as the parameter. Voila, when the lights come on, all the newly visible objects are automatically shown to the player, just as if they'd entered the room again.