local oldside = "Pakistan" --set name of old side local newside = "China" --set name of new side, must exist function changesSidesGroups(newSide, oldSide) --function number one local a = VP_GetSide({Side =oldSide}) -- get all units from old side local groups = {} --create empty array(table) to store group guids for i = 1, #a.units do -- loops thru all units on the side local u = ScenEdit_GetUnit({guid = a.units[i].guid}) --convert VP guid to Unit wrapper if u.type == 'Group' then -- check if group, if so add the group guid to the table table.insert(groups, u.guid) print(u.name.. " side: "..u.side ) --testing by printing to console end --closes if statement end --closes loop for i = 1, #groups do --loop thru new table of group guids print(groups[i]) --testing by printing to console ScenEdit_SetUnitSide({side=oldSide, guid=groups[i], newside=newSide}) --change side from old to new end --closes loop changeSidesUnits(newSide, oldSide) -- call second function to change units that are not in groups end --closes function function changeSidesUnits(newSide,oldSide) --function number two for non grouped units local a2 = VP_GetSide({Side =oldSide}) -- get all units from old side - won't include groups as they are already done local units = {} --create another empty table for i = 1, #a2.units do --loop thru units and push them into the table table.insert(units, a2.units[i].guid) end --closes loop for i = 1, #units do --loop thru table of units print(units[i]) --testing by printing to console ScenEdit_SetUnitSide({side=oldSide, guid=units[i], newside=newSide}) --change side end --closes loop end -- closes second function changesSidesGroups(newside, oldside) --call function number one to do all the magic stuff, it will call function number two.