Jump to content

Recommended Posts

Posted

Is there a way to retrieve the names of units within a group?

 

And do unit names have to be unique across groups?

 

Example: if I have 2 groups of 2 units. Can both groups have units with the names 'Unit truck' and 'Unit AAA'?

314-я смешанная авиационная дивизия

314th Mixed Aviation Division: The "Fighting Lemmings"- Forums: http://314thsquadron.enjin.com/ - ED Forum Group: http://forums.eagle.ru/group.php?groupid=119

Posted

Unit names are unique.

 

You would end up with 'Unit truck', 'Unit truck #001', Unit truck #002', ...

 

Can't answer the other question, though.

 

WC

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Posted

I might be inclined to look at the CTTS script since you seem to know your way around code and he seems to have figured out to pull certain units into his script ( with particular unit names)

 

Sorry I can't be more help.

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Posted

If you have a group name or group object you can use Group.getUnits() which returns a table of unit objects. From there you can iterate through each item and use Unit.getName() on the object.

 

Likewise if you have a single units name or unit object you can use Unit.getGroup() followed by what was described above.

 

for i, unitTable in pairs(Unit.getByName('myUnit'):getGroup():getUnits()) do

env.info(Unit.getName(unitTable))

end

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
If you have a group name or group object you can use Group.getUnits() which returns a table of unit objects. From there you can iterate through each item and use Unit.getName() on the object.

 

Likewise if you have a single units name or unit object you can use Unit.getGroup() followed by what was described above.

 

for i, unitTable in pairs(Unit.getByName('myUnit'):getGroup():getUnits()) do

env.info(Unit.getName(unitTable))

end

 

That was straight forward.

 

But I don't see any mention of Unit.getName in part 1 or 2 of the scripting engine pages http://wiki.hoggit.us/view/Simulator_Scripting_Engine_Documentation.

314-я смешанная авиационная дивизия

314th Mixed Aviation Division: The "Fighting Lemmings"- Forums: http://314thsquadron.enjin.com/ - ED Forum Group: http://forums.eagle.ru/group.php?groupid=119

  • 8 years later...
Posted
On 12/20/2013 at 2:55 AM, Grimes said:

for i, unitTable in pairs(Unit.getByName('myUnit'):getGroup():getUnits()) do

env.info(Unit.getName(unitTable))

end

@Grimes 

I am trying to get a unit name from a 'banditGroup' could you explain this syntax 

pairs(Unit.getByName('myUnit'):getGroup():getUnits())

especially the use 1) ":"  2) and where to you call for particular group to dig in? 

Posted (edited)
4 hours ago, Yuriks said:

...could you explain this syntax...

the complete line means for each value, refered as unitTable, inside the table of Units made of all units from the group that the Unit named 'myUnit' belongs to, do what follows in the code.

Unit.getByName('myUnit'):getGroup():getUnits() is the same than Group.getUnits(Unit.getGroup(Unit.getByName('myUnit')))

Edited by toutenglisse
corrected
  • Thanks 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...