d0ppler Posted 6 hours ago Posted 6 hours ago are these two IF statements practically IDENTICAL, or will getsize() occur sooner/later than the other? if myAIGroup:getsize() < 1 then -- code here end if not myAIGroup then -- code here end A-10C, AV-8B, Ka-50, F-14B, F-16C, F-5E, F/A-18C, L-39, Mi-8, MiG-21, MiG-29, SA34, Spitfire, Su-27, Su-33, UH-1H
Sano Posted 4 hours ago Posted 4 hours ago (edited) The order of the calls depend on where they are added. In your above code, the first "if" will always be called before the second "if". They also are not entirely identical: if "myAIGroup" is not a table with a "getSize()" method, for example when it's nil, some random string or number, the if-check will throw an error. So again, depending on how and where it's used, it's generally safer to do: if not group or (group and group:getSize() == 0) then -- ... end This first checks if the group does not exist (so is dead), or if it still exists, it should not have units. There's also a small mistake in your snippet, getSize() should be with capital S. Edited 4 hours ago by Sano
Recommended Posts