Jump to content
Atlas1205

"Undefined Variable"...

Recommended Posts

This is a script I use to create task and check if the goal is achieved (disarming mines):

[millead, "nextlv"] call IP_fnc_removeConversation;
MM1NOTGET = FALSE;publicvariable "MM1NOTGET";
["main1", ["Main: Mind the mines", "Disarm or destroy all mines on the bridge.<br /><br />Reward: $2000"], true] call ENGTASKS_SetTaskDescription;["main1", getpos mine_6, false] call ENGTASKS_SetTaskDestination;
{_x allowdamage true;_x hideobjectglobal false;_x enablesimulation true;} foreach [mine,mine_1,mine_2,mine_3,mine_4,mine_5,mine_6,mine_7,mine_8,mine_9,car,mg1,mg1g,mg2,mg2g,sb1,sb2,sb3,sb4];

//spawn enemies
nul = execvm "scripts\M1MM1SPAWN.sqf";

//Task done, go get paid
while {true} do {
if (((!alive mine) && (!alive mine_1) && (!alive mine_2) && (!alive mine_3) && (!alive mine_4) && (!alive mine_5) && (!alive mine_6) && (!alive mine_7) && (!alive mine_8) && (!alive mine_9)) && !(MM1NOTGET)) exitwith
{MM1GETPAID = TRUE; publicvariable "MM1GETPAID";
["main1", ["Main: Mind the mines  - Reward", "All mines are disarmed. I should head back to the militia leader for my reward, and get ready to move north.<br /><br />Reward: $2000"], true] call ENGTASKS_SetTaskDescription;
["main1", getpos millead, false] call ENGTASKS_SetTaskDestination;
};
};

Why did showscripterror say "mine" and others(without quotation marks, obviously) are "undefined variable in expression" when this script was executed WHILE.... guess what, all mines were manually named in editor as mine, mine_1, mine_2, etc.

The task was also triggered and finished as expected, nothing wrong at all, but the script error message remained there and didnt go away until the mission ended.

Help please? :dontgetit:

Share this post


Link to post
Share on other sites

I'm sure the -showScriptErrors hands out a bit more information than that, line number etc.

Saying "mine" throws an undefined variable in expression error doesn't really help finding the error.

How and where are you calling that function?

Did you use any debugging?

Also I'd throw a sleep into that while true loop.

Additionally you could make your function more readable if you put all mines into an array and replace these multiple !alive mine_N with

{!alive _x} count _myMines isEqualTo count _myMines;

 

Cheers

Share this post


Link to post
Share on other sites
31 minutes ago, Grumpy Old Man said:

I'm sure the -showScriptErrors hands out a bit more information than that, line number etc.

Saying "mine" throws an undefined variable in expression error doesn't really help finding the error.

How and where are you calling that function?

Did you use any debugging?

Also I'd throw a sleep into that while true loop.

Additionally you could make your function more readable if you put all mines into an array and replace these multiple !alive mine_N with


{!alive _x} count _myMines isEqualTo count _myMines;

 

Cheers

thanks for your help, I'll see what i can do first :f:

Share this post


Link to post
Share on other sites
35 minutes ago, Grumpy Old Man said:

I'm sure the -showScriptErrors hands out a bit more information than that, line number etc.

Saying "mine" throws an undefined variable in expression error doesn't really help finding the error.

How and where are you calling that function?

Did you use any debugging?

Also I'd throw a sleep into that while true loop.

Additionally you could make your function more readable if you put all mines into an array and replace these multiple !alive mine_N with


{!alive _x} count _myMines isEqualTo count _myMines;

 

Cheers

btw it marked  if (((!alive /#/mine) && (!alive mine_1) && (!alive mine_2) as undefined variable, i guess it was saying the line i used to check if mines are still intact has an error of this kind.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×