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
Code help: Trigger when lit
The worst submarine Offline
Junior Member

Posts: 11
Threads: 2
Joined: Oct 2010
Reputation: 0
#1
Code help: Trigger when lit

Hi! I'm trying to have the 01_house.map load when the player turns on candlestick1, but I am miserable when it comes to code. Can anyone lend me a hand? Thanks. Smile
10-02-2010, 09:03 PM
Find
HakePT Offline
Junior Member

Posts: 49
Threads: 1
Joined: Sep 2010
Reputation: 0
#2
RE: Code help: Trigger when lit

Don't think you can make a player change lvls on anything other than a lvl door.
Still there may be a way but i don't know it.
10-02-2010, 09:38 PM
Find
Jordo76 Offline
Member

Posts: 57
Threads: 7
Joined: Sep 2010
Reputation: 0
#3
RE: Code help: Trigger when lit

It's possible :
CODE :
void InteractCandle(string &in asEntity)
{
ChangeMap("01_house","StartPosHere","StartSoundHere","EndSoundHere");
}
NON CODE :
Put InteractCandle in Interact Callback of the Candle (in the editor)
It MIGHT work

Edit : Work but it work even if you haven't any Tinderbox,Make sure the player has one tinderbox so he will light her automatically
10-02-2010, 09:46 PM
Website Find
The worst submarine Offline
Junior Member

Posts: 11
Threads: 2
Joined: Oct 2010
Reputation: 0
#4
RE: Code help: Trigger when lit

(10-02-2010, 10:29 PM)The worst submarine Wrote: Thanks! I'll give it a shot and report back.
Worked like a charm! I think to fix the no-tinderbox problem, I'll have the candle disappear until a player gets a tinderbox, replaced by a candle without the callback function. Once they have one, it'll reappear.
(This post was last modified: 10-02-2010, 10:49 PM by The worst submarine.)
10-02-2010, 10:29 PM
Find
Noj Offline
Junior Member

Posts: 11
Threads: 2
Joined: Oct 2010
Reputation: 0
#5
RE: Code help: Trigger when lit

(10-02-2010, 10:29 PM)The worst submarine Wrote:
(10-02-2010, 10:29 PM)The worst submarine Wrote: Thanks! I'll give it a shot and report back.
Worked like a charm! I think to fix the no-tinderbox problem, I'll have the candle disappear until a player gets a tinderbox, replaced by a candle without the callback function. Once they have one, it'll reappear.

cant you just do a if condition in the script?
scripting fuctions in the documents says theres bool hasitem
you should be able to use that. (I havent started any scripting yet so i acnt answer on how...)
10-02-2010, 11:15 PM
Find
The worst submarine Offline
Junior Member

Posts: 11
Threads: 2
Joined: Oct 2010
Reputation: 0
#6
RE: Code help: Trigger when lit

(10-02-2010, 11:15 PM)Noj Wrote: cant you just do a if condition in the script?
scripting fuctions in the documents says theres bool hasitem
you should be able to use that. (I havent started any scripting yet so i acnt answer on how...)
Yeah I noticed that too, it seems a lot easier. Thanks. Smile
10-02-2010, 11:18 PM
Find
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#7
RE: Code help: Trigger when lit

Candles actually have an option in their entity options called CallbackFunc, and one of the Types it can function as is 'OnIgnite', much easier with much less inventory checking. Basically, you define a function name for it to point to, for example I tested it with 'testignite' as the function name. Then, in your script, you have something like this:

void testignite(string &in EntityName, string &in Type)
{
    if(Type == "OnIgnite")
    {
        AddDebugMessage("Ignited_callback_scare", false);
        PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
    }
}

In that fully functional sample, when the candle is ignited with a tinderbox, it sends out a debug message and a scary sound.
10-03-2010, 03:19 AM
Find
The worst submarine Offline
Junior Member

Posts: 11
Threads: 2
Joined: Oct 2010
Reputation: 0
#8
RE: Code help: Trigger when lit

(10-03-2010, 03:19 AM)Entih Wrote: Candles actually have an option in their entity options called CallbackFunc, and one of the Types it can function as is 'OnIgnite', much easier with much less inventory checking. Basically, you define a function name for it to point to, for example I tested it with 'testignite' as the function name. Then, in your script, you have something like this:

void testignite(string &in EntityName, string &in Type)
{
    if(Type == "OnIgnite")
    {
        AddDebugMessage("Ignited_callback_scare", false);
        PlaySoundAtEntity("rawr", "guardian_ontop.snt", "Player", 0.0f, false);
    }
}

In that fully functional sample, when the candle is ignited with a tinderbox, it sends out a debug message and a scary sound.
I finally got the code working, and then I decided to come back and say that I'd finished. Now I find a much, much easier way to do what I've done! Haha. Thanks, I'll definitely replace my code with this. Much less loopholes.
10-03-2010, 03:27 AM
Find




Users browsing this thread: 4 Guest(s)