gpotter511
Posts: 52
Joined: 10/4/2017 Status: offline
|
EDIT: On further review, I think I may have resolved this by appending "Tool_EmulateNoConsole(true)". If I'm interpreting this correctly, the function is failing because I'm using the console. But, if I were to utilize the below script in an Action, the "~=nil" language would ensure the script successfully completes. Can folks confirm? Thank you! ORIGINAL MESSAGE: All - I've been playing around with the use of "if, then" phrases and nil functions this weekend. My ultimate objective is to move aircraft to an OPFOR base once that base has been "captured". I'm successfully able to accomplish this for units known to exist. Trouble arises when I attempt to ensure a series of such moves will occur even if one indicated unit is destroyed. If I am moving Eagle #1-#3, and Eagle #2 has been destroyed, then the script fails. My script is virtually identical to this example pulled from CMANO Chains of War's "Okinawa Bound" mission: if ScenEdit_GetUnit({Side='Japan-United States', Name='Strike Group 1'}) ~= nil then ScenEdit_AssignUnitToMission('Strike Group 1', 'Strike Group 1 Task 3') end if ScenEdit_GetUnit({Side='Japan-United States', Name='Strike Group 2'}) ~= nil then ScenEdit_AssignUnitToMission('Strike Group 2', 'Strike Group 2 Task 2') end if ScenEdit_GetUnit({Side='Japan-United States', Name='JDS Soryu'}) ~= nil then ScenEdit_AssignUnitToMission('JDS Soryu','Okinawa Phib Zone') end if ScenEdit_GetUnit({Side='Japan-United States', Name='JDS Takashio'}) ~= nil then ScenEdit_AssignUnitToMission('JDS Takashio','Okinawa Phib Zone') end I would think the purpose of the "~= nil" portion of this function is that, if a given unit - say, Strike Group 2 - has been destroyed, CMANO will recognize that unit is "nil", disregard that statement, and move on to subsequent functions. But despite the "~= nil" language, an error message is served and the remainder of the script is not executed. Can anyone describe the appropriate modifications to ensure that, if a unit is "nil", CMANO will continue on and perform the remainder of the script? Thanks!
< Message edited by gpotter511 -- 7/22/2018 8:43:29 PM >
|