Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Iterate over defined Sides...

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Iterate over defined Sides... Page: [1]
Login
Message << Older Topic   Newer Topic >>
Iterate over defined Sides... - 6/5/2020 8:31:57 PM   
jkgarner

 

Posts: 72
Joined: 4/30/2020
Status: offline
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.


Post #: 1
RE: Iterate over defined Sides... - 6/6/2020 3:21:40 AM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
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_GetSides() 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.
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.


< Message edited by KnightHawk75 -- 6/6/2020 3:34:08 AM >

(in reply to jkgarner)
Post #: 2
RE: Iterate over defined Sides... - 6/6/2020 10:27:45 AM   
jkgarner

 

Posts: 72
Joined: 4/30/2020
Status: offline
Thanks...

(in reply to KnightHawk75)
Post #: 3
RE: Iterate over defined Sides... - 6/9/2020 9:04:57 AM   
jkgarner

 

Posts: 72
Joined: 4/30/2020
Status: offline
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?

(in reply to jkgarner)
Post #: 4
RE: Iterate over defined Sides... - 6/9/2020 11:54:31 AM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
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. 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.




< Message edited by KnightHawk75 -- 6/9/2020 11:56:03 AM >

(in reply to jkgarner)
Post #: 5
RE: Iterate over defined Sides... - 6/9/2020 1:37:43 PM   
jkgarner

 

Posts: 72
Joined: 4/30/2020
Status: offline
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...

It's great to have access to the forum, where someone may know a bit more.
Thanks for your help.

(in reply to KnightHawk75)
Post #: 6
RE: Iterate over defined Sides... - 6/9/2020 8:54:14 PM   
KnightHawk75

 

Posts: 591
Joined: 11/15/2018
Status: offline
quote:

ORIGINAL: jkgarner
I have no way of knowing what methods are missing from the documentation.
So I'll keep muddling through and asking questions...

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.

(in reply to jkgarner)
Post #: 7
RE: Iterate over defined Sides... - 6/18/2020 6:42:11 PM   
jkgarner

 

Posts: 72
Joined: 4/30/2020
Status: offline
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).


(in reply to KnightHawk75)
Post #: 8
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Iterate over defined Sides... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.127