how to make no nav zone inactive

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
orca
Posts: 545
Joined: Wed Nov 06, 2013 4:59 pm

how to make no nav zone inactive

Post by orca »

I'm trying to inactive a no nav zone.

The no nav zone is names Vagar SAM and the side is USSR. I tried this but it doesn't work.

ScenEdit_SetZone('USSR', 'Vagar SAM', isactive=false)

Thanks
User avatar
stilesw
Posts: 1572
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: how to make no nav zone inactive

Post by stilesw »

Hi Orca,

I've used this to accomplish what you are looking for:

First run this in the Lua console to determine the zone you want to set. In this case it was [5] for me

local a = VP_GetSide({Side ='Coalition'})
local z = a.nonavzones
print (z)
{ [1] = { description = 'No-Fly Iraq', guid = '1a4b27c0-8046-47aa-874c-061272b8a6d2' }, [2] = { description = 'No-Fly Lebanon', guid = '6b169452-f024-4b4e-8c42-88e945db6d4e' }, [3] = { description = 'No-Fly Syria', guid = '36adbdc7-47ee-467f-961d-0b695f707a4a' }, [4] = { description = 'No-Fly Egypt', guid = 'f6dc7a7b-21b7-448e-bb74-80fe4b536c7d' }, [5] = { description = 'Bunker Zone', guid = '9619cdea-3078-479a-bbe5-b5ea81565b63' } }
==================================================================================
Once you know that then you can set the specific zone with this Lua code:

local a = VP_GetSide({Side ='Coalition'})
local z = a.nonavzones
local n5 = a : getnonavzone(z[5].guid)
n5.isactive = true

You can use the last line to turn the zone both on and off.

Hope it helps,

-WS

“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
orca
Posts: 545
Joined: Wed Nov 06, 2013 4:59 pm

RE: how to make no nav zone inactive

Post by orca »

thanks. got it to work!
User avatar
BeirutDude
Posts: 2799
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: how to make no nav zone inactive

Post by BeirutDude »

local a = VP_GetSide({Side ='Coalition'})
local z = a.nonavzones
local n5 = a : getnonavzone(z[5].guid)
n5.isactive = true

Wayne,

Just used this code. TY!!!
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: how to make no nav zone inactive

Post by KnightHawk75 »

If you don't know (added\remove on the fly) or otherwise don't want to lookup the index\guid ahead of time.
-- Takes string sidename, string zonename (name or guid of the nonavzone),setting as true|false
-- returns true if the change took place, otherwise false on error detection or bad parameters.

Code: Select all

 function setNoNavStatusOnSideByNameorGuid(theside,zonename,setting)
   fn="setNoNavStatusOnSideByNameorGuid(): ";
   if theside ==nil or zonename ==nil or setting==nil then print(fn.. "invalid params, aboring."); return false;end
   if type(theside) ~='string' or type(zonename) ~='string' or type(setting)~='boolean' then print(fn.. "param of invalid type, aborting"); return false; end
   local retval,s = pcall(VP_GetSide,{Side=theside});
   if (retval ==true) and s~=nil then
     local z = s.nonavzones 
     if (z ~=nil) and #z > 0 then 
       for i=1,#z do
         if z[i].description == zonename or z[i].guid == zonename then
           local retval,nz = pcall(s.getnonavzone,s,z[i].guid);
           if (retval ==true) and nz~=nil then nz.isactive = setting; return true; end
         end
       end
       print(fn.. "NoNav zone " .. tostring(zonename) .." not found.");
     else
       print(fn.. "NoNav zone " .. tostring(zonename) .." not found.");
     end
   else
     print(fn.. "Side " .. tostring(theside) .. "not found.");
   end
   return false;
 end
 
setNoNavStatusOnSideByNameorGuid("Coalition","No-Fly Egypt",false)
setNoNavStatusOnSideByNameorGuid("Coalition","No-Fly Syria",true)
Post Reply

Return to “Lua Legion”