SOLVED Creating a Light Switch - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: SOLVED Creating a Light Switch (/thread-18254.html) Pages:
1
2
|
SOLVED Creating a Light Switch - Frodos - 09-10-2012 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 RE: Creating a Light Switch - Adny - 09-10-2012 How would you like the lights to be turned on, button, lever or wheel? RE: Creating a Light Switch - Frodos - 09-10-2012 Lever. RE: Creating a Light Switch - Tomato Cat - 09-10-2012 Try something like this. Code: void OnStart() RE: Creating a Light Switch - Frodos - 09-10-2012 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. RE: Creating a Light Switch - Adny - 09-10-2012 You have two functions with the same name; please post your full script so we can help RE: Creating a Light Switch - Frodos - 09-10-2012 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); } } RE: Creating a Light Switch - Tomato Cat - 09-10-2012 Change the name to jacobroomfunc2 or something. RE: Creating a Light Switch - Adny - 09-10-2012 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. RE: Creating a Light Switch - Tomato Cat - 09-10-2012 Or that. xD |