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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Candle scripting help
Hatred Offline
Junior Member

Posts: 10
Threads: 3
Joined: Feb 2012
Reputation: 1
#1
Candle scripting help

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.
(This post was last modified: 05-23-2012, 08:23 PM by Hatred.)
05-23-2012, 08:17 PM
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#2
RE: Candle scripting help

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%

05-23-2012, 08:40 PM
Find
Hatred Offline
Junior Member

Posts: 10
Threads: 3
Joined: Feb 2012
Reputation: 1
#3
RE: Candle scripting help

Thank you very much for your quick response!
I'll try this right away and inform if it does work or not.
05-23-2012, 08:42 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#4
RE: Candle scripting help

Quick question, do you want a particular order to how the candles are lit or it doesn't matter?
05-23-2012, 08:54 PM
Find
Hatred Offline
Junior Member

Posts: 10
Threads: 3
Joined: Feb 2012
Reputation: 1
#5
RE: Candle scripting help

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. Smile
(This post was last modified: 05-23-2012, 09:11 PM by Hatred.)
05-23-2012, 09:10 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Candle scripting help

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

Trying is the first step to success.
05-24-2012, 07:49 PM
Find
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#7
RE: Candle scripting help

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: (Select All)
int prevCandle 0;
int combo 1;
void OnStart()
{
     for(
int x 1<= 5x++)
     {
          
SetEntityCallbackFunc("candlestick_wall_"+x"MyFunc");
     }
}

void MyFunc(string &in asEntitystring &in type//This function is ran when a player interacts with a candle
{
//GET WHICH CANDLE NUMBER. In my case I have candles candlestick_wall_1 thru candlestick_wall_5
for(int x 1<= 5x++)
{
     if(
asEntity == "candlestick_wall_"+x)
     {
          
int curCandle x;
     }
}

if(
curCandle == (prevCandle 1))
{
     
combo++;
}
else
{
     
combo 1//if they break the combo, set combo back to 1.
//also, set all the candles here to turn off as to restart the puzzle
curCandle 0//This allows you to start from 1 again.
}
//now check for if you have lit candle 5 while keeping the combo up

if(combo == && curCandle == 5)
{
     
//run code for solving  puzzle here
     
return;
}

//At the end of this block, make sure you set the curCandle to prevCandle
prevCandle curCandle;


Dark Seclusion Here
(This post was last modified: 05-24-2012, 09:19 PM by FragdaddyXXL.)
05-24-2012, 08:56 PM
Find




Users browsing this thread: 1 Guest(s)