Page 1 of 1

Trouble with LUA / Activation & Deactivation of No-Navigation Zones

Posted: Fri Jun 09, 2017 6:17 am
by Fer_Cabo
Hi guys,

I'm having trouble with a LUA instruction for an Action that deactivates an existing and active No-Navigation Zone.

What i found in CMANO manuals and sample scripts is as follows:

mySide = VP_GetSide({Name=”US”})
myZone = mySide:getnonavzone(“AAW Zone 1”)
myZone.isactive = ”False”

In my Scenario case, the script would be as follows, for an Action deactivating the initially activated No-Navigation-Zone defined for "DPRK" side units on Chinese Territory (the No-Navigation Zone is called "PRCSOVEREIGN"), once the side "PRC" has been attacked and the Mutual Defence Agreement between the two countries/Sides enters into effect:

mySide = VP_GetSide({Name=”DPRK”})
myZone = mySide:getnonavzone(“PRCSOVEREIGN”)
myZone.isactive = ”False”

The problem is... when i test this LUA Script in the Script Console, it returns ERROR based on a character position (148) which does not even exist, since the script is apparently not so long.

What'd be the right scripting?

Thanks a (metric)Ton in advance for your help!

Fernando.



RE: Trouble with LUA / Activation & Deactivation of No-Navigation Zones

Posted: Fri Jun 09, 2017 8:02 am
by michaelm75au
Would be easier to see what problem is if you attach the scenario?
The error should report what line the error occurred on.

RE: Trouble with LUA / Activation & Deactivation of No-Navigation Zones

Posted: Fri Jun 09, 2017 8:11 am
by Fer_Cabo
Thanks Michael, but the error only reports unexpected character in position 148 (no line reference - besides, there are only 3 lines in the script).

Thought it could be a typo just like using some Capital letters: GetNonavzone vs. getnonavzone, but doesn't work either

RE: Trouble with LUA / Activation & Deactivation of No-Navigation Zones

Posted: Fri Jun 09, 2017 8:33 am
by michaelm75au
I assume you are using the latest version (1.12+)
The " isn't needed around the false.

If you can zip and attach the scenario, I can probably give a clearer answer.
I don't know it is just how it shows, but the quotes marks around DRPK and PRCSOVEREIGN seem to be different.
mySide = VP_GetSide({Name=DPRK})
myZone = mySide:getnonavzone(PRCSOVEREIGN)

Try using the single quote ' instead.

RE: Trouble with LUA / Activation & Deactivation of No-Navigation Zones

Posted: Sat Jun 10, 2017 9:26 am
by Fer_Cabo
mySide = VP_GetSide({Name="DPRK"})
myZone = mySide:getnonavzone("PRCSOVEREIGN")
myZone.isactive = False

It works like this!

Thanks a lot!