| 
		
	
		| Frodos   Junior Member
 
 Posts: 28
 Threads: 7
 Joined: Sep 2012
 Reputation: 
0
 | 
			| SOLVED Creating a Light Switch 
 
				Hey guys,
 I am working on a modern custom story, there's a room that is dark, in the middle of the room a light hangs from the ceiling. I've seen in other custom stories light switches that can turn on lights in the room. Could someone give me a tutorial on how to do this? I want the switch to turn on just the one light in the room.
 
 I prefer with pictures, since I'm new at scripting and quite slow, but a tutorial without any pictures is fine.
 
 Thanks
 
 Veteran Writer
 Need help with your CS plot? PM me!
 
 Noob Scripter, need help PM me.
 
 
 
 
 
 
				
(This post was last modified: 09-10-2012, 05:58 AM by Frodos.)
 |  |  
	| 09-10-2012, 05:01 AM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Creating a Light Switch 
 
				How would you like the lights to be turned on, button, lever or wheel?
			 
 I rate it 3 memes. |  |  
	| 09-10-2012, 05:03 AM |  |  
	
		| Frodos   Junior Member
 
 Posts: 28
 Threads: 7
 Joined: Sep 2012
 Reputation: 
0
 | 
			| RE: Creating a Light Switch 
 
				Lever.
			 
 Veteran Writer
 Need help with your CS plot? PM me!
 
 Noob Scripter, need help PM me.
 
 
 
 
 
 |  |  
	| 09-10-2012, 05:05 AM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Creating a Light Switch 
 
				Try something like this. void OnStart(){
 SetEntityConnectionStateChangeCallback("whatever","whateverthefunc");
 }
 
 void whateverthefunc(string &in asEntity, int alState)
 {
 if(alState == 1)
 {
 SetLampLit("lampname", true, true);
 }
 
 if(alState == -1)
 {
 SetLampLit("lampname",false,true);
 }
 }
 RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ 
				
(This post was last modified: 09-10-2012, 05:30 AM by Tomato Cat.)
 |  |  
	| 09-10-2012, 05:08 AM |  |  
	
		| Frodos   Junior Member
 
 Posts: 28
 Threads: 7
 Joined: Sep 2012
 Reputation: 
0
 | 
			| RE: Creating a Light Switch 
 
				I tried and I'm getting a error when I try to launch the story.
 FATAL ERROR: Could not load script file 'customs stories/csa/maps/csa/csa.hps'! main (5,1) : ERR : A function with the same name and parameters already exist.
 
 This what I did after interpreting your suggestion.
 
 In "whatever" I put in the name of the lever.
 
 "In whateverthefunc" I put "jacobroomfunc"
 
 Then in the editor, I put "jacobroomfunc" in the levers Callback Func
 
 In "lampname" I put the name of the lamp.
 
 Veteran Writer
 Need help with your CS plot? PM me!
 
 Noob Scripter, need help PM me.
 
 
 
 
 
 |  |  
	| 09-10-2012, 05:38 AM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Creating a Light Switch 
 
				You have two functions with the same name; please post your full script so we can help   
 I rate it 3 memes. |  |  
	| 09-10-2012, 05:40 AM |  |  
	
		| Frodos   Junior Member
 
 Posts: 28
 Threads: 7
 Joined: Sep 2012
 Reputation: 
0
 | 
			| RE: Creating a Light Switch 
 
				void OnStart(){
 
 
 }
 void OnStart()
 {
 SetEntityConnectionStateChangeCallback("jacobwrbedswitch","jacobroomfunc");
 }
 
 
 void jacobroomfunc(string &in asEntity, int alState)
 {
 if(alState == 1)
 {
 SetLampLit("Jacob_WR_Lamp", true, true);
 }
 
 
 if(alState == -1)
 {
 SetLampLit("Jacob_WR_Lamp",false,true);
 }
 }
 
 Veteran Writer
 Need help with your CS plot? PM me!
 
 Noob Scripter, need help PM me.
 
 
 
 
 
 |  |  
	| 09-10-2012, 05:44 AM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Creating a Light Switch 
 
				Change the name to jacobroomfunc2 or something.
			 
 RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ |  |  
	| 09-10-2012, 05:49 AM |  |  
	
		| Adny   Posting Freak
 
 Posts: 1,766
 Threads: 6
 Joined: Mar 2012
 Reputation: 
173
 | 
			| RE: Creating a Light Switch 
 
				You had two OnStart's, here's a revision:
 
 void OnStart()
 {
 SetEntityConnectionStateChangeCallback("jacobwrbedswitch","jacobroomfunc");
 }
 
 
 void jacobroomfunc(string &in asEntity, int alState)
 {
 if(alState == 1)
 {
 SetLampLit("Jacob_WR_Lamp", true, true);
 }
 
 
 if(alState == -1)
 {
 SetLampLit("Jacob_WR_Lamp",false,true);
 }
 }
 
 Hope that helped.
 
 I rate it 3 memes. |  |  
	| 09-10-2012, 05:54 AM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Creating a Light Switch 
 
				Or that. xD
			 
 RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ |  |  
	| 09-10-2012, 05:56 AM |  |  |