unit_auto_com_group.lua - Page 2

unit_auto_com_group.lua

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: unit_auto_com_group.lua

Post 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?
User avatar
troycheek
Posts: 80
Joined: 22 May 2009, 19:13

Re: unit_auto_com_group.lua

Post 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. :-)
Attachments
unit_auto_group_com.lua
(1.14 KiB) Downloaded 105 times
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: unit_auto_com_group.lua

Post 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 ()
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: unit_auto_com_group.lua

Post by manolo_ »

works good, also in team games
Post Reply

Return to “Lua Scripts”