Frictional Games Forum (read-only)
[SCRIPT] Candle trigger - 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: [SCRIPT] Candle trigger (/thread-22379.html)



Candle trigger - VillainousPotato - 08-10-2013

I'm looking for a script that calls a function when 2 specific candles are lit.But I need it to happen only after both of them are lit. I cant find it in any tutorial but maybe I'm just not looking for it in the right place.


RE: Candle trigger - PutraenusAlivius - 08-10-2013

You need to set a Local Variable Integer (SetLocalVarInt) then add it (AddLocalVarInt) then check it (If-Else code). The codes you need (it's not the full code. It's just the code to all three stuff) for all three.

Spoiler below!

For the Integer that adds up so that the checker can be done.
Code:
void OnStart()
{
SetLocalVarInt("Candles", 0);
//other codes....
}

For the Incrementer that adds the Integer values.
Code:
AddLocalVarInt("Candles", 1);

For the checker that checks the two candles.
Code:
if(GetLocalVarInt("Candles") == 2)
{
//function caller....
}

else
{
}




RE: Candle trigger - VillainousPotato - 08-10-2013

(08-10-2013, 11:17 AM)JustAnotherPlayer Wrote: You need to set a Local Variable Integer (SetLocalVarInt) then add it (AddLocalVarInt) then check it (If-Else code). The codes you need (it's not the full code. It's just the code to all three stuff) for all three.

Spoiler below!

For the Integer that adds up so that the checker can be done.
Code:
void OnStart()
{
SetLocalVarInt("Candles", 0);
//other codes....
}

For the Incrementer that adds the Integer values.
Code:
AddLocalVarInt("Candles", 1);

For the checker that checks the two candles.
Code:
if(GetLocalVarInt("Candles") == 2)
{
//function caller....
}

else
{
}

so would i use an interaction callback to call the Adding function?


RE: Candle trigger - Damascus - 08-10-2013

You'll actually need a general callback, something that's pretty versatile for triggering scripts. Here's an example from my script:

SetEntityCallbackFunc("torch_static01_2", "LightTorch");

void LightTorch(string &in asEntity, string &in OnIgnite)
{
AddTimer("", 0.5f, "SwitchTorch");
}

Make sure your function is labelled as "OnIgnite," as above. For other uses, you can put in OnPickup or Break, but I don't have a full list of functions. Smile


RE: Candle trigger - VillainousPotato - 08-11-2013

(08-10-2013, 10:55 PM)Damascus Wrote: You'll actually need a general callback, something that's pretty versatile for triggering scripts. Here's an example from my script:

SetEntityCallbackFunc("torch_static01_2", "LightTorch");

void LightTorch(string &in asEntity, string &in OnIgnite)
{
AddTimer("", 0.5f, "SwitchTorch");
}

Make sure your function is labelled as "OnIgnite," as above. For other uses, you can put in OnPickup or Break, but I don't have a full list of functions. Smile
Awesome thanks! It works like a charm after about 100 tries. but i got it! victory is sweet.