[SCRIPT] Candle scripting help - 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 scripting help (/thread-15589.html) |
Candle scripting help - Hatred - 05-23-2012 Hi everybody. I made a room with 5 candles in the center of it and now I want that when you have lit all the candles, in order from 1 to 5, it sets something active, like a key on the floor. All help appreciated. RE: Candle scripting help - Obliviator27 - 05-23-2012 Use SetLocalVarInt, and AddLocalVarInt. Like so. void OnStart() { SetLocalVarInt("CandlesLit", 0); // Sets a variable "CandlesLit" to zero. SetEntityCallbackFunc("candlename", "CandleLight"); // Replace candlename with the names of your candles, and call as many times as there are candles. Could be done under the interactcallback tab of the candle itself. } void CandleLight(string &in asEntity, string &in type) { if(asType == OnIgnite) // If it's ignited. { AddLocalVarInt("CandlesLit", 1); if(GetLocalVarInt("CandlesLit") == 5) // If the variable is equal to five, execute following statement { //SetEntityActive script goes here, along with anything else. } } } Written off of the top of my head, so I'm not sure if it'll work 100% RE: Candle scripting help - Hatred - 05-23-2012 Thank you very much for your quick response! I'll try this right away and inform if it does work or not. RE: Candle scripting help - Rapture - 05-23-2012 Quick question, do you want a particular order to how the candles are lit or it doesn't matter? RE: Candle scripting help - Hatred - 05-23-2012 Order from candle 1 to 5. For example if the candles are in a straight row like this candle1 candle3 candle5 candle2 candle4 you would have to light the candle 1 first and then candle 2 and so on. And if you light them in wrong order, nothing would happen. @Obliviator27 It worked almost perfectly, only this order thing did not work. Still, thanks for your help. Much appreciated. RE: Candle scripting help - FlawlessHappiness - 05-24-2012 Then you have to make the script a litte longer and make every candle-script individual. Something like, if candle 1 is lit, then add 1 when lighting candle 2. If candle 2 is lit then add 1 when lighting candle 3 RE: Candle scripting help - FragdaddyXXL - 05-24-2012 Or, you could keep track of your recent lit candle with a prevCandle and curCandle. (Previous and current). You'll also need a variable to keep track of how many you currently have in-a-row. Set that variable to 1. When player lights a second candle, check to see if it's next in line: PHP Code: int prevCandle = 0; |