Exception handling – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (rv. hack)
Line 5: Line 5:
== firebomb.sqs example ==
== firebomb.sqs example ==
The first if in the '''firebomb.sqs'' example is incorrect.
The first if in the '''firebomb.sqs'' example is incorrect.
you are using a || = conditional OR here, so the code ''throw "vehicle empty"'' will be executed if  one of the conditions returns true. your intention was to get this code exectued when there is nobody in the vehicle, so you should use
you are using a || = conditional OR here, so the code ''throw "vehicle empty"'' will be executed if  one of the conditions returns true. your intention was to get this code exectued when there is nobody in the vehicle, so you should use && = conditional AND. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) would be much more effective. --[[User:TeRp|TeRp]] 20:40, 22 July 2006 (CEST)
 
:: You are right. I didn't know about crew command. --[[User:Djura|Djura]] 20:48, 22 July 2006 (CEST)

Revision as of 08:38, 11 April 2007

Can the if statement handle numbers? Because emptyPositions returns a number and not a boolean. --T_D 20:07, 22 July 2006 (CEST)

IMHO every number larger than zero means true. --Djura 20:38, 22 July 2006 (CEST)

firebomb.sqs example

The first if in the 'firebomb.sqs example is incorrect. you are using a || = conditional OR here, so the code throw "vehicle empty" will be executed if one of the conditions returns true. your intention was to get this code exectued when there is nobody in the vehicle, so you should use && = conditional AND. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) would be much more effective. --TeRp 20:40, 22 July 2006 (CEST)

You are right. I didn't know about crew command. --Djura 20:48, 22 July 2006 (CEST)