Frictional Games Forum (read-only)
Code help: Trigger when lit - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Code help: Trigger when lit (/thread-4892.html)



Code help: Trigger when lit - The worst submarine - 10-02-2010

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


RE: Code help: Trigger when lit - HakePT - 10-02-2010

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.


RE: Code help: Trigger when lit - Jordo76 - 10-02-2010

It's possible :
Code:
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


RE: Code help: Trigger when lit - The worst submarine - 10-02-2010

(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.


RE: Code help: Trigger when lit - Noj - 10-02-2010

(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...)


RE: Code help: Trigger when lit - The worst submarine - 10-02-2010

(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


RE: Code help: Trigger when lit - Entih - 10-03-2010

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:

Code:
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.


RE: Code help: Trigger when lit - The worst submarine - 10-03-2010

(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:

Code:
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.