Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Creating a Light Switch
Frodos Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2012
Reputation: 0
#1
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
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
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
Find
Frodos Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2012
Reputation: 0
#3
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#4
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
Find
Frodos Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2012
Reputation: 0
#5
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
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: Creating a Light Switch

You have two functions with the same name; please post your full script so we can help Smile

I rate it 3 memes.
09-10-2012, 05:40 AM
Find
Frodos Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2012
Reputation: 0
#7
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#8
RE: Creating a Light Switch

Change the name to jacobroomfunc2 or something.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
09-10-2012, 05:49 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#9
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
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#10
RE: Creating a Light Switch

Or that. xD

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
09-10-2012, 05:56 AM
Find




Users browsing this thread: 1 Guest(s)