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
Scripting help needed
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#1
Scripting help needed

Okay so im scripting this file, and whenever i script maps it seems like SOMETHING ALWAYS has to go wrong. This time it crashes and says:

FATAL ERROR: Could not load (script file)!
main (21, 1) :ERR :Expected expression value
main (27, 1) :ERR :Expected expression value

I copied and pasted the script so far into this thread, plz tell me what im doing wrong cuz im starting to get pissed off, seems like i always mess up one tiny little thing that crashes the entire map.

void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 4.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_11", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_12", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_13", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_14", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_16", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 2.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_18", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_19", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_21", 2.0f, "");
    AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", false, 1);
AddEntityCollideCallback("servant_grunty_1", "AreaDisableGrunt", "Func02", false, 1);
PlayMusic("00_creak.ogg", true, 1.0f, 0.0f, 0, true);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     if (HasItem("lantern_1") == true)
     {
          SetEntityActive("servant_grunt_1", true);
          RemoveEntityCollideCallback("Player", "AreaActivateGrunt");
          return;
     }
}
void Func02(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", false);
}
(This post was last modified: 05-28-2011, 04:47 AM by willochill.)
05-28-2011, 04:47 AM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#2
RE: Scripting help needed

Try taking the RemoveEntityCollideCallback("Player", "AreaActivateGrunt"); out and instead changing the boolean value regarding auto-remove callback on collide to true. Then change your if statement to re-add the collide callback if the player doesn't have the lantern. I've been staring at your script and nothing looks wrong.

I have however, experienced issues with removing collide callbacks in a function that is called by the collision itself.

(This post was last modified: 05-28-2011, 07:20 AM by palistov.)
05-28-2011, 07:18 AM
Find
willochill Offline
Member

Posts: 73
Threads: 27
Joined: Apr 2011
Reputation: 0
#3
RE: Scripting help needed

what do you mean by the second suggestion, "change the if statement to re-add the collide callback if the player doesn't have the lantern?" could you show that to me in script?
05-28-2011, 03:55 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#4
RE: Scripting help needed

Of course. That means you change AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", false, 1); to true. False says that the function will be repeatedly called when the player enters the area. Changing it to true means the callback will happen only once.

Once you do that, you change your if statement to:

void Func01(string &in asParent, string &in asChild, int alState)
{
if(!HasItem("lantern_1")) { AddEntityCollideCallback("Player", "AreaActivateGrunt", "Func01", true, 1); return; }
if(HasItem("lantern_1") SetEntityActive("grunt_1", true);
}

The first if statement says that when the player does not have a lantern, the callback will be re-added. If the player does have the lantern, the first if statement will be ignored and the monster will be activated, without re-adding the callback. It does exactly what your script does, but without removing callbacks via script.

(This post was last modified: 05-29-2011, 10:33 AM by palistov.)
05-29-2011, 10:29 AM
Find




Users browsing this thread: 1 Guest(s)