Page 1 of 1
No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 8:39 am
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.
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 3:49 pm
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.
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 4:21 pm
by Parel803
thanks, great.
appriciate the help
regards Gert-Jan
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 4:48 pm
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

RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 4:57 pm
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

RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 5:20 pm
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.
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.
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 5:42 pm
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.
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 5:43 pm
by Parel803
second try
Looks a bit that the second ones initiated RefPoints are on teh Crosses of Lat/Long?

RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 6:08 pm
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
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 6:32 pm
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.
RE: No-Nave zone with AddZone
Posted: Mon Feb 15, 2021 6:39 pm
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.
RE: No-Nave zone with AddZone
Posted: Tue Feb 16, 2021 9:33 am
by Parel803
thx again, probable it.
Gonna try some more on hte duplications
regards Gert-Jan