Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LAMP CALLBACK PLEASE HELP
Author Message
Itskody Offline
Member

Posts: 100
Joined: Mar 2011
Reputation: 1
Post: #1
LAMP CALLBACK PLEASE HELP
How do i trigger an event when i light a lamp?
09-17-2011 09:25 PM
Find all posts by this user Quote this message in a reply
Elven Offline
Posting Freak

Posts: 868
Joined: Aug 2011
Reputation: 26
Post: #2
RE: LAMP CALLBACK PLEASE HELP
void SetEntityCallbackFunc(string& asName, string& asCallback);
Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc

there you go Smile

The Interrogation
Chapter 1

My tutorials
09-17-2011 09:33 PM
Find all posts by this user Quote this message in a reply
Khyrpa Offline
Senior Member

Posts: 615
Joined: Apr 2011
Reputation: 24
Post: #3
RE: LAMP CALLBACK PLEASE HELP
Or you can do this inside the level editor:
[Image: bloblitlampinteractthin.jpg]

Then add this in your script file:

void LightAndThisHappens(string &in asEntity)
{
//Stuff you want done
}

09-17-2011 09:43 PM
Find all posts by this user Quote this message in a reply
Itskody Offline
Member

Posts: 100
Joined: Mar 2011
Reputation: 1
Post: #4
RE: LAMP CALLBACK PLEASE HELP
yea but how do i make it so something only happens when all 3 lights are lit Sad
09-18-2011 05:30 AM
Find all posts by this user Quote this message in a reply
Khyrpa Offline
Senior Member

Posts: 615
Joined: Apr 2011
Reputation: 24
Post: #5
RE: LAMP CALLBACK PLEASE HELP
Should be something similar to this

void OnStart()
{
for(int n=1;n<3;n++) SetEntityPlayerInteractCallback("LampName_"+n, "LampLitCallback", true);
}

void LampLitCallback(string &in asEntity)
{AddLocalVarInt("CheckHowmany", 1); //Adds 1 each time a lamp is lit to the variable
if(GetLocalVarInt("CheckHowmany") == 3){//DO STUFF}
}

09-18-2011 10:30 AM
Find all posts by this user Quote this message in a reply
Itskody Offline
Member

Posts: 100
Joined: Mar 2011
Reputation: 1
Post: #6
RE: LAMP CALLBACK PLEASE HELP
ok soo it would look like this?

void OnStart()
{
for(int n=1;n<3;n++) SetEntityPlayerInteractCallback("Lamp_01"+n, "LampLitCallback", true);
}

void LampLitCallback(string &in asEntity)
{AddLocalVarInt("3", 1); //Adds 1 each time a lamp is lit to the variable
if(GetLocalVarInt("3") == 3){//DO STUFF}
}



and that means that when 3 lights are lit it will trigger an effect?
09-18-2011 04:28 PM
Find all posts by this user Quote this message in a reply
Khyrpa Offline
Senior Member

Posts: 615
Joined: Apr 2011
Reputation: 24
Post: #7
RE: LAMP CALLBACK PLEASE HELP
for(int n=1;n<3;n++) SetEntityPlayerInteractCallback("Lamp_01"+n, "LampLitCallback", true);

is the same thing as

SetEntityPlayerInteractCallback("Lamp_011", "LampLitCallback", true);
SetEntityPlayerInteractCallback("Lamp_012", "LampLitCallback", true);
SetEntityPlayerInteractCallback("Lamp_013", "LampLitCallback", true);

09-18-2011 04:42 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)