Page 1 of 1
Iterate over defined Sides...
Posted: Fri Jun 05, 2020 5:31 pm
by jkgarner
There is: ScenEdit_AddSide()
There is: ScenEdit_RevomeSide()
And there are various ScenEdit_SetSide??? functions.
But no ..._GetSide, or ..._GetSideList functions, that I can tell looking at the documentation.
How does on iterate over the sides in a scenario?
Or even check if a side exists before attempting to add it (potentially again) and having it fail for the user.
RE: Iterate over defined Sides...
Posted: Sat Jun 06, 2020 12:21 am
by KnightHawk75
Iterate over list of all sides (ie when you don't know the names ahead of time) requires build 1142_2 or later, I forget which exact build but VP_GetSide
s() was relatively recently added and has not made it's way into the documentation yet though it should be in the selection drop down in the Lua console. VP_GetSide has been around for ages and is in the documentation.
Code: Select all
local allSides = VP_GetSides(); --returns a indexed table of sides.
for k,v in pairs(allSides) do
print(string.format("side[%d] name: %s guid: %s", k, v.name, v.guid))
end
--check if a side exists basic
if VP_GetSide({name='United States'}) ~=nil then --note it can be non-nil error message though.
print("side exists as return value was non-nil");
end
--check if a side exist extended.
local function sideExists(sideName)
local retVal,sObj = pcall(VP_GetSide,{name=sideName}); --suppress error if one happens
if((sObj~=nil and retval==true) and sObj.guid~=nil) then --was a successful call and the object isn't an error msg.
return true;
end
return false; --default\anything else happens return false;
end
if sideExists('United States') then print('Exists!');
else print('Does not exist!');
end
If using professional edition you may not have access to VP_GetSides() yet, though it's possible the very latest build has it.
RE: Iterate over defined Sides...
Posted: Sat Jun 06, 2020 7:27 am
by jkgarner
Thanks...
RE: Iterate over defined Sides...
Posted: Tue Jun 09, 2020 6:04 am
by jkgarner
This function is not listed on the CommandLua Documentation page (
https://commandlua.github.io/)
The unit condition or condition_v (e.g. underway, airborne, etc) is not listed/enumerated in the documentation.
I wonder: how many other functions and states are not listed? [&:]
RE: Iterate over defined Sides...
Posted: Tue Jun 09, 2020 8:54 am
by KnightHawk75
There are some. I notice if we bring it up it usually gets corrected (time permitting I'm sure). For instance VP_GetSides is now in the docs after this thread. [:D] Tool_UIwindow() might be another, and the recent EMCON and specific sensor enable\disabling tweaks I think need to make it in somewhere (maybe they have and I didn't notice where yet).
Devs are pretty good about updating it if someone points it out.
I noticed future additions was added on the news page as well.
I'm stoked about being able to addUnit on weapons, should make life easier when trying to spawn in certain types of attacks.
RE: Iterate over defined Sides...
Posted: Tue Jun 09, 2020 10:37 am
by jkgarner
I saw that VP_GetSides is now in the documentation.[:)]
I am glad the devs are responsive to complaints about missing functions in the documentation...[:)]
This provides a way to improve the documentation for future users.
Unfortunately, I don't know what I don't know...
Nor am I practised in the throwing of runes,
nor am I "The Great Canac" (see:
Johnny Carson as the Great Carnac )[;)]
I have no way of knowing what methods are missing from the documentation.
So I'll keep muddling through and asking questions... [8|]
It's great to have access to the forum, where someone may know a bit more.
Thanks for your help.[:)]
RE: Iterate over defined Sides...
Posted: Tue Jun 09, 2020 5:54 pm
by KnightHawk75
ORIGINAL: jkgarner
I have no way of knowing what methods are missing from the documentation.
So I'll keep muddling through and asking questions... [8|]
Yup lol. If I implied otherwise it wasn't intentional at all. Yeah that's what I do, ask questions, sometimes there is an easy answer, sometimes not so much or something is there but not obvious (fields vs wrapper properties), and sometimes we get a new feature or function extended to solve a given challenge. Your more than welcome, I try to do what I can in paying it forward in that regard.
RE: Iterate over defined Sides...
Posted: Thu Jun 18, 2020 3:42 pm
by jkgarner
What version of Command supports VP_GetSides?
I am running Professional Edition Academic/Student version 1.14.2 (1.15 is still beta)
When I call the function, I get a "your are referencing a nil object (VP_GetSides).