Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

'Nil' Functions, Error Handling, and Destroyed Units

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> 'Nil' Functions, Error Handling, and Destroyed Units Page: [1]
Login
Message << Older Topic   Newer Topic >>
'Nil' Functions, Error Handling, and Destroyed Units - 7/22/2018 8:33:41 PM   
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 >
Post #: 1
RE: 'Nil' Functions, Error Handling, and Destroyed Units - 7/24/2018 1:59:57 PM   
tjhkkr


Posts: 2428
Joined: 6/3/2010
Status: offline
Hey there, can you cut and paste the error you are receiving?

_____________________________

Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.

(in reply to gpotter511)
Post #: 2
RE: 'Nil' Functions, Error Handling, and Destroyed Units - 7/26/2018 11:11:07 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Yes, I created the Tool_EmulateNoConsole(true) function to allow you run event type scripts in the Console to check if they run okay.

_____________________________

Michael

(in reply to tjhkkr)
Post #: 3
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> 'Nil' Functions, Error Handling, and Destroyed Units Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.078