Jump to content
[GLT] Legislator

Using countSide is resulting in "Error Type Bool, expected Bool"

Recommended Posts

Hello

 

for years I've been using this code in my init.sqf to check for ingame conditions.

if (isServer) then {
	
	// Task 1 PATROL
	[] spawn { 
		 waitUntil {((west countSide (list trg1)) > 0)};
			nul = ["task1", "Succeeded"] execVM "\glt_core\scripts\tasks\task.sqf";
			
			obj1 = true;
			publicVariable "obj1";
			
			"patrol1" setMarkerColor "ColorRed";
			"patrol1" setMarkerType "mil_objective";
			"patrol1" setMarkerText localize "STR_GLT_Task_Goal_Secure_Area";
	};
};

Since the last big game update it resulting into this error however:

 

17:59:27 Error in expression <aitUntil {((west countSide (list trg1)) > 0)};
nul = ["task1", "Succeeded"] exec>
17:59:27   Error position: <> 0)};
nul = ["task1", "Succeeded"] exec>
17:59:27   Error Type Bool, expected Bool
 

I checked the condition ingame using the debugging console: a = west countSide list trg1;

Results:
a = 0

obj1 = true

 

So apparently the condition is skipped because of the error and the code is executed before it should be. Can anyone confirm if this is an intended behaviour now or a game bug? What can I do to prevent this error? This is a very big issue for me as I'm using this code in more than 80 missions. Thanks to anyone in advance.

Share this post


Link to post
Share on other sites

@[GLT] Legislator,

@Dedmen said to me earlier,

Quote

I think I know. exitWith {} might return nil. Since Arma 1.94 (last update) returning nil in a waitUntil is an error. Previously it was handled as a "false".
The old code was wrong anyway, the exitWith needs to return true to exit the waitUntil, old code caused infinite loop and since the last game update (which's aim was to fix infinite waitUntil loops) it's an error.

I hope that helps.

  • Like 2

Share this post


Link to post
Share on other sites

Oh dear god ... while it makes sense not to have this infinite loop that is considered unclean coding anyway it had no negative impact on my small missions. 

Share this post


Link to post
Share on other sites
15 hours ago, [GLT] Legislator said:

while it makes sense not to have this infinite loop that is considered unclean coding anyway it had no negative impact on my small missions

You had no negative impact, because it was not a infinite loop.
trg1 is probably undefined when the waitUntil starts, thus right now it instantly errors.
Previously it just kept endless looping until trg1 got defined maybe a second or so later, at which point your script just ran perfectly fine and the waitUntil did what you expected it to do.

Share this post


Link to post
Share on other sites
16 hours ago, [GLT] Legislator said:

Error Type Bool, expected Bool

 

weird one

Share this post


Link to post
Share on other sites
6 minutes ago, gc8 said:

 

weird one

Nope.

 

You just have to know how to read it correctly. Sadly BI is a bit unclear here.
Let me translate:


Error got Nil of type Bool, Expected a non-nil bool.

  • Like 3

Share this post


Link to post
Share on other sites

Speaking of the devil

 

Quote

Tweaked: waitUntil will now continue looping when incorrectly returning something instead of true / false, and show a warning. We strongly recommend fixing scripts, because we intend to force exiting the loop again in 1.96.

 

Oh. I guess that's my fault
firefox_2019-08-02_11-03-49.png

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
49 minutes ago, Dedmen said:

You just have to know how to read it correctly.

 

lol. they really need to change that message 🙂

 

Share this post


Link to post
Share on other sites

This is the message I get if trg1 is undefined

12:43:20 Error in expression <pawn {waitUntil {((west countSide (list trg1)) > 0)};}>
12:43:20   Error position: <trg1)) > 0)};}>
12:43:20   Error Undefined variable in expression: trg1
12:43:20 Error in expression <aitUntil {((west countSide (list trg1)) > 0)};}>
12:43:20   Error position: <> 0)};}>
12:43:20   Error Type Bool, expected Bool
 

What happened to Undefined variable in OP's error message?

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

×