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 Mind-boggling "SetEntityCallbackFunc" issue
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#1
Mind-boggling "SetEntityCallbackFunc" issue

I'm working on a script triggered after player picks up two items. What I used are two
PHP Code: (Select All)
SetEntityCallbackFunc 
functions triggered to add 1 to local variable, which is then checked via the functions if it equals 2. However, the issue is that for some reason it doesn't want to work.

Here is the broken piece of code:

PHP Code: (Select All)
void OnStart()
{
    
/////callback func
    
SetEntityCallbackFunc("orbpiece_turquoise_1""check_1");
    
SetEntityCallbackFunc("lantern_1""check_2");
}

void check_2(string &in asEntitystring &in asType)
{
    
check();
    
AddLocalVarInt("var_pick"1);
}

void check_1(string &in asEntitystring &in asType)
{
    
check();
    
AddLocalVarInt("var_pick"1);
}

void check() 
{
    if(
GetLocalVarInt("var_pick") == 2)
    {
        
AutoSave();
        
CheckPoint("save_orb_redux_02""checkpoint_1""""Hints""BeCarefulYouSilly");
        
GiveSanityBoost();
        
AddTimer("spawn_warden"4.0f"warden_scene");
    }
}

void warden_scene(string &in asTimer)
{
    
AddEffectVoice("placeholder""""Dialogues""CH01L09_Alodar_1"false"Player"5.0f100.0f);
    
AddQuest("get_out2""get_outta_here2");
    
SetEntityActive("shadow_appear"true);
    
SetEntityActive("warden_placeholder_good_1"true);
    for(
int i=1;i<=11;i++)
    { 
        
AddEnemyPatrolNode("warden_placeholder_good_1""PathNodeArea_"+i0.01f"");
    }


Any ideas? Thanks ahead of time
(This post was last modified: 05-27-2016, 12:42 AM by Slanderous.)
05-27-2016, 12:31 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Mind-boggling "SetEntityCallbackFunc" issue

Try adding the variable before check();. You're getting your desired output of 2, but it's doing the check before.

First pass:

Check
Local Var = 0, so don't check.
Local Var = 1.

Check
Local Var = 1, so don't check.
Local Var = 2.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
05-27-2016, 12:54 AM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#3
RE: Mind-boggling "SetEntityCallbackFunc" issue

(05-27-2016, 12:54 AM)Romulator Wrote: Try adding the variable before check();. You're getting your desired output of 2, but it's doing the check before.

First pass:

Check
Local Var = 0, so don't check.
Local Var = 1.

Check
Local Var = 1, so don't check.
Local Var = 2.

Thanks, that worked like a charm! Had no clue that the solution was so simple.
05-27-2016, 01:04 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Mind-boggling "SetEntityCallbackFunc" issue

No problem mate Smile The main thing to remember that code is sequential, practically always working top-down.

Closing~ :3

Discord: Romulator#0001
[Image: 3f6f01a904.png]
05-27-2016, 01:58 AM
Find




Users browsing this thread: 2 Guest(s)