Newbie Switch ???

spoke01
15 May 2013, 21:42
1st - Thanks goes out to all for the help
2nd - PC version 5.4.1

I'm having a terrible timing setting up a light switch. Here's where I am and what I want to do.

a) I'm in a hallway (h5) and I want to go DOWN to an unlit basement (bs1).

b) I want it so the basement (bs1) is dark and have a light switch available there. Before going DOWN, the switch must be turned ON. Once it's turned on, everything becomes visible (just like real life). The switch would be set as "weak".

c) Plus (if possible), not be able to leave the basement (UP) before turning the light back OFF (optional). This would put me back in the hallway (h5).

I know this isn't too hard to set up, but it's making me pull my hair out and I don't have much left. I just can't get it to work.
If someone could give me a step by step set of instructions (I'm fairly familiar with the editor), I sure would appreciate it.

While I'm waiting, I'm going to the bar, grab some "brews" and wait there for your answer(s). Thanks ahead of time. :D

george
15 May 2013, 22:45
I just wrote out a long explanation of how to make a three way light switch, but re-reading your question I'm not sure if that's what you want. Do you want a switch in the basement and the hallway, or just the basement?

Sora574
16 May 2013, 01:44
spoke01 wrote:b) I want it so the basement (bs1) is dark and have a light switch available there. Before going DOWN, the switch must be turned ON. Once it's turned on, everything becomes visible (just like real life). The switch would be set as "weak".


[list=1][*]As you've already stated, the light switch needs to be 'weakly lit' ('Options' tab => 'This object is a lightsource' => 'Weak')[/*:m]
[*]Stay in the options tab and make it a switch ('Switchable: Can be switched on/off')[/*:m]
[*]Add this to the 'After switching on the object' script:
[Set a variable or attribute] bs1.dark = false
[/*:m]
[*]Add this to the 'After switching off the object' script:
[Set a variable or attribute] bs1.dark = true
[/*:m][/list:o]

As for not being able to go down if the switch is off, that's not possible unless there's a switch in the hallway. Otherwise some unknown force would have to turn the switch on before you go in.

spoke01 wrote:c) Plus (if possible), not be able to leave the basement (UP) before turning the light back OFF (optional)

[list=1][*]Go to the 'Exit' tab in the exit going from the basement to the hallway[/*:m]
[*]Click the checkbox 'Run a script (instead of moving player automatically)'[/*:m]
[*]Add this to that script:
[if...] bs1.dark
[...then] [Move object] <!--Change 'object' to 'expression'--> game.pov [to] h5
[...else] [Print message] Turn the light off first.
[/*:m][/list:o]

This should do what you want, unless I'm mistaken on what exactly it is that you want, in which case a few easy minor adjustments can be made to the code.

P.S. Remember to make sure that the exit leading from 'bs1' to 'h5' is weakly illuminated ('Options' tab)
Otherwise, you wouldn't be able to leave the room if the light was off.

EDIT: Thanks for clearing it up.

HegemonKhan
16 May 2013, 02:43
my understanding is that he~she wants the light switch to be turned on first as a requirement, before you can go down to the basement. You're not allowed to go down while the basement remains unlit.

HK EDIT:

I think he~she wants it merely so that upon entering and exiting the basement, the basement light source is switched on and off respectively.

Which is a simple matter of putting the scripts on what part of the code that is a part of the transition into and out of the basement.

I still haven't worked with the light source coding yet (lol), too busy now with school and etc (hardly get to work on much quest for the time being of while going to school), otherwise I'd give you a step by step guide for it.

Sora574
16 May 2013, 02:47
HegemonKhan wrote:my understanding is that he~she wants the light switch to be turned on first as a requirement, before you can go down to the basement. You're not allowed to go down while the basement remains unlit.

If that's the case, then they could just move/copy the switch to the hallway.
Then maybe add a script to the exit going from the hallway to the basement.
Of course, if you're not allowed in the basement unless it's lit, then you would need to move the player out of it once the basement switch is switched (if there is one).

HegemonKhan
16 May 2013, 02:50
I re-read it again more closely, as my first read was a lazy and incomplete read lol, and so have just edited my last post.

I think he~she just wants it to be switched on and off as you enter and leave the basement.

or...

maybe a combination of both, argh... I'm confused now too... laughs.

Sora574
16 May 2013, 02:55
I think we should wait for the TC to clarify what they mean.
Honestly, if you don't go into the basement unless the hallway switch is on, then the basement doesn't actually have to be 'dark'. You just need a few 'if/thens' in the exit, pertaining to the switch.

spoke01
16 May 2013, 11:55
To all:

I tried to make my post simple, but I think I may have added to many "options" and didn't make it clear enough. Sorry about that.

Oh yea, I'm a 67 y.o. male in W.Va., U.S.

(the following might be slightly different than the original request)

a) I want to go from a hallway (h5) DOWN to a basement (bs1) which is by default dark .

b) There would be a light switch to TURN ON in the basement before I could do anything or search the other 5 basement "rooms".

c) Once the searching is complete, and upon wanting to leaving the basement, I would have toTURN OFF the light before being able to go back UP to the hallway.


Is all this possible using the GUI program or without fancy coding? Is "Sora574" correct that it can be done with "if/thens"?

My problem is getting the switch to work right. I tried different settings and I just can't get it right. I realize it sounds like it should be simple to do, but until I see how it's setup, I'm stuck. From your replies, it sounds like it might be tricky to do that.

spoke01
16 May 2013, 11:57
george wrote:I just wrote out a long explanation of how to make a three way light switch, but re-reading your question I'm not sure if that's what you want. Do you want a switch in the basement and the hallway, or just the basement?

I've decided "just in the basement". Please read my second post here somewhere.

Liam315
16 May 2013, 12:26
Hi, that should all be easily achievable just using the GUI. So going step by step, you need to:

a) I want to go from a hallway (h5) DOWN to a basement (bs1) which is by default dark .

Select the Basement, go to the 3rd tab labelled "light/dark" and check the box labelled "room is initially dark. You should include an alternate description here to indicate that the player can find the light switch e.g. "The room is pitch black, but by running your hands along the wall you locate what you think is a light switch."


b) There would be a light switch to TURN ON in the basement before I could do anything or search the other 5 basement "rooms".

- Create an object in the basement named light switch (or whatever codename you want to use).
- Go to the options tab and from the first box select "object can be switched on/off. Once you've done that an option will appear called "after switching on the object." Click 'add a script' and down near the bottom of the pop up menu there will be an option for "make room light." Select that and choose the basement for the room.
- Finally down the bottom of the same tab is a box labelled "object is a light source." Select that and choose "weak" from the drop down menu. Weak light sources can be used even when the room is dark but they do not illuminate the room.


c) Once the searching is complete, and upon wanting to leaving the basement, I would have toTURN OFF the light before being able to go back UP to the hallway.

For this one you need to do a few things.
- First you need to make sure that the exit from the basement to the hall has a name. (Select the exit and add whatever you want to call it to the name field.)
- While you're here, you should add a message to the field marked "Print message when locked," something along the lines of "didn't your father ever teach you not to waste electricity?" so that the player knows they are blocked by the fact they've left the light on.
- Then go to the options tab for the exit, select "object is a light source" and set it to weak.
- Then go back to your light switch object and add another script to the "after switching on the light switch" and choose lock exit, and select the exit you just named.
- Finally, to unlock the exit again once the light is turned off, there is a similar section under the one you've been using called "after switching off the object." You need to add two scripts here, "make room dark" and "unlock exit."

Hope this helps :)

Sora574
16 May 2013, 20:07
spoke01 wrote:I've decided "just in the basement". . .

Personally, I don't like using the game's built-in locks, as you can't currently run scripts from the exit (as far as I know) when it is locked -- you can only print a message.
However, feel free to use either of mine or Liam's tutorials. They should do more or less the same thing.

spoke01
17 May 2013, 12:52
I ended up using parts of just about everybody's suggestions and finally have it working - somewhat. I just left off the part where the player has to turn off the light to go back up to the hallway. I entered text that said it will go off by itself (crude, but it reads right).

Thanks to all who tried to help. As I get better at this, I may be able to help others.

:D

spoke01
20 May 2013, 18:52
spoke01 wrote:I ended up using parts of just about everybody's suggestions and finally have it working - somewhat. I just left off the part where the player has to turn off the light to go back up to the hallway. I entered text that said it will go off by itself (crude, but it reads right).

Thanks to all who tried to help. As I get better at this, I may be able to help others.

:D

It took a while, but I got it working by my MOVING my player/object back to the Hallway after turning the light off.

guzmere
20 May 2013, 20:14
And now to really complicate things why don't you put the light switch on a timer :lol: :lol: Terry :D Happy Adventuring :D