[WAD] ScenEdit_SetUnitSide

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
User avatar
tjhkkr
Posts: 2431
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

[WAD] ScenEdit_SetUnitSide

Post by tjhkkr »

ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

After using the command, the ScenEdit_SetUnitSide did change the single unit airfield, but it would not let me use any of the aircraft stationed on it.
An issue?

Thank you!

Image
Attachments
Untitled.jpg
Untitled.jpg (195.86 KiB) Viewed 60 times
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
RoryAndersonCDT
Posts: 1826
Joined: Mon Jun 15, 2009 11:45 pm

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by RoryAndersonCDT »

Thanks, Logged
Command Dev Team
Technical Lead
RoryAndersonCDT
Posts: 1826
Joined: Mon Jun 15, 2009 11:45 pm

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by RoryAndersonCDT »

Further investigation, this isn't a bug, would need to change the side of those hosted units as well via Lua.
Command Dev Team
Technical Lead
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by michaelm75au »

SetUnitSide() will change all the units in group. But for hosted units, you need to change the units based there. We can't assume all units at the base should change side, as the designer may only want certain ones to change to one side or the other.
Michael
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by michaelm75au »

Example of how to affect the hosted units:

Code: Select all

-- find the wrapper for the airfield
 local unit = ScenEdit_GetUnit( {name='RAAF Darwin/Darwin International', guid='aeeca904-d5de-4850-a208-bddd7c2f41b0'})
 print(unit.hostedUnits )
 -- loop thru the hosted aircraft
 for i =1, #unit.hostedUnits['Aircraft'] 
 do 
    -- get the wrapper for the aircraft
    local u = ScenEdit_GetUnit( { guid=unit.hostedUnits['Aircraft'][i] } )
    -- change the side of the unit
    u = ScenEdit_SetUnitSide( {side=u.side, name=u.guid, newside= 'Neutral' })
    -- response should be true/false if it worked
 end
 -- change side of the base
 ScenEdit_SetUnitSide( {side=unit.side, name=unit.guid, newside= 'Neutral' })
Michael
User avatar
tjhkkr
Posts: 2431
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by tjhkkr »

Baloogan... THANK YOU very much as always.

michaelm75au A double thank you for the code to do this... :) SINCERELY appreciated.

May I place your example into the LUA CODE repository? Others could benefit from this...
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_SetUnitSide does not allow me to use the aircraft after changing sides.

Post by michaelm75au »

My Lua is your Lua [:D]
Michael
Post Reply

Return to “Tech Support”