Page 2 of 2

Re: unit_auto_com_group.lua

Posted: 13 Jul 2009, 18:06
by Niobium
manolo_ wrote:couldnt it just detect the unit that is at the startpoint? and could it autpgroup if upgrade my boi?
Spring.GetTeamStartPosition(teamID) -> x, y, z
Spring.GetUnitsInCylinder(x, y, z, r, [teamID]) -> unit table

For upgrade, detect issued morph command and monitor?

Re: unit_auto_com_group.lua

Posted: 15 Jul 2009, 10:22
by troycheek
Pendrokar wrote: (Spring.GetUnitTeam(unitID) == Spring.GetMyTeamID)
Or maybe

Code: Select all

local allUnits = Spring.GetTeamUnits(Spring.GetMyTeamID())
I stole that from quantum's Select n Center! for my own version (attached below). Works for me but I don't do multiplayer or replays, so I don't know how it reacts that that. This version can also be reloaded in the middle of the game to re-group the Commander after a morph or whatever.

As for morph/upgrade staying with the group, that probably should be handled in the unit_morph.lua gadget. It already reassigns units guarding the original commander to guard the morphed one in the function ReAssignAssists(newUnit,oldUnit). I also found where it makes sure selected units are still selected after a morph in the function SelectSwap(cmd, oldID, newID). One of these functions could probably fairly easily be changed to also check unit groups and assign the morphed unit to the same group. Then it's just a matter of convincing all your favorite mod authors to use your updated gadget. :-)

Re: unit_auto_com_group.lua

Posted: 15 Jul 2009, 11:41
by Pendrokar
Good you're learning. I threw functionality not performance(Although this function would launch once and on a few units)... 8)

BTW
(Spring.GetUnitTeam(unitID) == Spring.GetMyTeamID)
the latter wouldn't work because of no ()

Re: unit_auto_com_group.lua

Posted: 15 Jul 2009, 19:27
by manolo_
works good, also in team games