Detach unit form group

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Detach unit form group

Post by Parel803 »

I made a group but wanna detach 1 unit at a setTrigger.
I've learned how to detach a ship by giving her another group (group of 1)
Wondering if it's possible to detach her without she being in another group.
If it's on the forum please sen the link, could nog find it.

with regards GJ
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Detach unit form group

Post by michaelm75au »

From memory, it should be as simple as
<unit wrapper>.group = nil
Michael
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Detach unit form group

Post by Parel803 »

Thank you,
with regards GJ
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Detach unit form group

Post by Parel803 »

local u2 = ScenEdit_GetUnit({guid='50PVO4-xxx-U2T2SG'})
u2.group = nil

Am I in the correct direction here? Seems I'm not get this working.

Now made a new group for the dataching unit, that seems to work (group of 1)

Much appriciate the hulp

with regards GJ
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Detach unit form group

Post by Parel803 »

Thes was My stupidity so this Q deleted. Only try to find out how to detach an unit without making her another group.
with regards

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Detach unit form group

Post by KnightHawk75 »

local group1 = ScenEdit_GetUnit({name='Flight 509', guid='4FH7PU-0HM6D66BVSJBH'}) --get the group.
local u2 = ScenEdit_GetUnit({guid=group1.group.unitlist[2]}) --get the second unit of the group example.
u2.group = "" --don't use nil use ""
u2.mission = "" --assuming you want to clear it's mission too, idk.
u2.mission = "TestMission2" assign newly detached unit a new mission.
ScenEdit_AssignUnitToMission(group1.guid,"TestMission") -- you want to assign all of what's left of the group to another mission that exists.
--ScenEdit_AssignUnitToMission(group1.group.unitlist[1],"TestMission") --same thing just using single unitguid
Are you saying that doesn't work for you, does for me, but could be misreading what you want?


I will say after dropping the group member via lua there does appear to be a bug in the gui that still makes it think the dropped unit is still a group member (ie you can't regroup it in gui cause it thinks it's still grouped) though even though the system otherwise reports it as dropped in the log and if you look at it's properties it's not a member any more even though some gui features still thinks it is.


Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Detach unit form group

Post by Parel803 »

Knighthawk thank you. I'm gonna try again, had a stupid mistake for the mission. Sorry for your wasted time.
with regards GJ

But seeing that I used Nil instead of "". so thx again
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Detach unit form group

Post by KnightHawk75 »

I make the nil vs "" mistake sometimes too, but doesn't detach in my experience with nil, don't sweat it. :)

Actually "" doesn't really work either I just noticed if you actually aren't moving it from one group to another (most common), filing bug\enhancement report now.

ie if you want the detach to "no group", nil will fail, and "" will create a empty string new group.
So it would become something like
Local group1 = ScenEdit_GetUnit({name='Flight 509', guid='4FH7PU-0HM6D66BVSJBH'}) --get the group.
local u2 = ScenEdit_GetUnit({guid=group1.group.unitlist[2]}) --get the second unit of the group example.
u2.group = "" --don't use nil use "" to detach to new group called nothing "".
ScenEdit_DeleteUnit({guid=u2.group.guid}) -- then delete the new group.
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Detach unit form group

Post by michaelm75au »

My mistake.
u2.group = "none" should remove the unit from the group.
Michael
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Detach unit form group

Post by Parel803 »

thx Michael,
Appriciate your time and help
Gonna try

with regards GJ
Post Reply

Return to “Lua Legion”