Page 1 of 1
					
				 how to make no nav zone inactive
				Posted: Tue Jul 21, 2020 7:51 pm
				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
			 
			
					
				 RE: how to make no nav zone inactive
				Posted: Tue Jul 21, 2020 9:07 pm
				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
 
 
			 
			
					
				 RE: how to make no nav zone inactive
				Posted: Tue Jul 21, 2020 11:32 pm
				by orca
				 thanks.  got it to work!
			 
			
					
				 RE: how to make no nav zone inactive
				Posted: Tue Jul 20, 2021 10:26 am
				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!!!
 
			 
			
					
				 RE: how to make no nav zone inactive
				Posted: Wed Jul 21, 2021 1:38 am
				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)