No-Nave zone with AddZone

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

No-Nave zone with AddZone

Post by Parel803 »

I'm trying to add a no-nav zone via Lua and this works:
ScenEdit_AddZone('Blueland', 0, {description='TstNoNav', IsActive=false, affects={'aircraft', 'ship', 'submarine', 'facility'}, locked=true})
But when I try to add the area it gevies me:
ERROR: Kan een object van het type System.String niet converteren naar het type NLua.LuaTable.
This is my line:
ScenEdit_AddZone('Blueland', 0, {description='TstNoNav', IsActive=false, affects={'aircraft', 'ship', 'submarine', 'facility'}, locked=true, area={'t1','t2','t3','t4'}})

Sorry for the Dutch error line.

Hope someone sees my mistake and wants to tell me
with regards Gert-Jan

Had visible in it but quess that is not possible.
Attachments
tstNonav.zip
(10.01 KiB) Downloaded 7 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: No-Nave zone with AddZone

Post by KnightHawk75 »

Yeah the problem there is feeding it names when it expects actual RP objects which isn't obvious and I forget it from time to time as well.

The following should work for you (assuming the RP's in question pre-exist):

Code: Select all

local rps = ScenEdit_GetReferencePoints({side="Blueland", area={"t1","t2","t3","t4"}})
 ScenEdit_AddZone('Blueland', 0, {description='TstNoNav', IsActive=false, affects={'aircraft', 'ship', 'submarine', 'facility'}, locked=true, area=rps})
 --or 'inline' version
 ScenEdit_AddZone('Blueland', 0, {description='TstNoNav', IsActive=false, affects={'aircraft', 'ship', 'submarine', 'facility'}, locked=true, area=ScenEdit_GetReferencePoints({side="Blueland", area={"t1","t2","t3","t4"}}})
 
visible I think would be hidden=true|false.
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

thanks, great.
appriciate the help

regards Gert-Jan

Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

I'm trying the first option.
It makes the NoNav zone but copies the RefPoints with a slightly different position and the same name.
What am I doing wrong here??

Just added the site Blueland and 4 Refpoints.

with regards GJ


Image
Attachments
NoNav.jpg
NoNav.jpg (287.32 KiB) Viewed 422 times
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

Tried also the second option. Added 1x ) near the end.
Got the same result in duplicating the Ref Points.
Beyond my peanut brain capacity

regards GJ

Image
Attachments
NoNav2.jpg
NoNav2.jpg (302.21 KiB) Viewed 422 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: No-Nave zone with AddZone

Post by KnightHawk75 »

"Just added the site Blueland and 4 Refpoints. " -- um why create a new sample vs the one you provided?

Not sure what's going on there, loaded your sample nonav scene ran code above with the rp names (t1-t4) in that scene and it didn't duplicate anything.
Image

Did you actually create the rp1-4 or 5-8 first so they exist? They need to exist first before you send them to AddZone unless you want to generate them in-line.

So if they don't pre-exist you can have it create them for you _if_ you specify all the params in the call with all the new params to create them.
ie:
ScenEdit_AddZone('Blueland', 0, {description='TstNoNav', IsActive=false, affects={'aircraft', 'ship', 'submarine', 'facility'}, locked=true, area={{name=mynewrp1,latitude=1.0,longitude=1.0,hidden=false,locked=false},{name=mynewrp2,..etc..etc..},{etc..etc...etc},{etc..etc..etc..}}})
While handy, I generally avoid doing that as it can makes for more confusing code, preferring to just generate them first.

Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

Restart pc & game.
First attempt I added the refpoints via ctrl-RMB and run in the console.
Second attempt I added the refpoints via the console and the addzone.

Don't waste to much time on my stuff, probably something errorous at my side.

Attachments
NoNacRPs.zip
(85.32 KiB) Downloaded 12 times
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

second try
Looks a bit that the second ones initiated RefPoints are on teh Crosses of Lat/Long?

Image
Attachments
NoNavSecond.jpg
NoNavSecond.jpg (162.37 KiB) Viewed 422 times
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

I realize this has nothing to do with this subject but if I enter:
ScenEdit_AddUnit({Side='Blueland', type='Submarine', dbid=301, name='Dolfijn S808', latitude='14,2474414825439', longitude='91,4833084106445', Depth=100})

The sub is initiated on 14N 91E. Should it do that with the decimal positions?
Just curiosity

with regards GJ
Attachments
positions.jpg
positions.jpg (86.67 KiB) Viewed 422 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: No-Nave zone with AddZone

Post by KnightHawk75 »

I see what you mean, it's definitely duplicating them, interesting (was hard to tell with them locked, noticed it when I unlocked them all and moved some after the fact).

hmm.. so maybe the trick is to never pre-create them now so no dupes? That's a shame (not being able to use existing without getting dupes) and not how I remember this working long ago.

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: No-Nave zone with AddZone

Post by KnightHawk75 »

ORIGINAL: Parel803

I realize this has nothing to do with this subject but if I enter:
ScenEdit_AddUnit({Side='Blueland', type='Submarine', dbid=301, name='Dolfijn S808', latitude='14,2474414825439', longitude='91,4833084106445', Depth=100})

The sub is initiated on 14N 91E. Should it do that with the decimal positions?
Just curiosity

with regards GJ
try using periods instead of commas it's possible it may not handle region settings properly there on conversion during the add call so it's cutting off at the ",". You should be able to get precise placement at least out to 6 decimal places.

Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: No-Nave zone with AddZone

Post by Parel803 »

thx again, probable it.
Gonna try some more on hte duplications :-)

regards Gert-Jan
Post Reply

Return to “Lua Legion”