Page 1 of 1
Detach unit form group
Posted: Mon Jan 25, 2021 12:44 pm
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
RE: Detach unit form group
Posted: Wed Jan 27, 2021 2:35 am
by michaelm75au
From memory, it should be as simple as
<unit wrapper>.group = nil
RE: Detach unit form group
Posted: Wed Jan 27, 2021 6:00 pm
by Parel803
Thank you,
with regards GJ
RE: Detach unit form group
Posted: Tue Feb 09, 2021 1:25 pm
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
RE: Detach unit form group
Posted: Tue Feb 09, 2021 2:21 pm
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
RE: Detach unit form group
Posted: Tue Feb 09, 2021 4:57 pm
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.
RE: Detach unit form group
Posted: Tue Feb 09, 2021 4:59 pm
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
RE: Detach unit form group
Posted: Tue Feb 09, 2021 5:03 pm
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.
RE: Detach unit form group
Posted: Wed Feb 10, 2021 3:53 am
by michaelm75au
My mistake.
u2.group = "none" should remove the unit from the group.
RE: Detach unit form group
Posted: Wed Feb 10, 2021 7:49 am
by Parel803
thx Michael,
Appriciate your time and help
Gonna try
with regards GJ