Selected Unit (?contact) Damaged (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


Parel803 -> Selected Unit (?contact) Damaged (1/18/2022 1:18:00 PM)

Good afternoon,
Tried to get damage on a selected unit. Used the exampl from KH on
https://www.matrixgames.com/forums/tm.asp?m=4900919&mpage=1&key=ScenEdit%5FSelectedUnits�
Thanks for that. Didn't try it on a contact yet, next on the list.

I got it working in a special action except the message. Which I wanna make a message box. Since this is made with trial&error (instead of knowledge of it all) I'm sure It can be doen better, if someone sees stuuff to change it is much appriciated.

local sUnits=ScenEdit_SelectedUnits(); --get the list.
-- compile a list of all units and contacts.
local myTempTable = {}
if(sUnits.units ~=nil) then --validate it
for k,v in pairs(sUnits.units) do
table.insert(myTempTable,{name= v.name,guid = v.guid})
end
end
if(sUnits.contacts ~=nil) then
for k,v in pairs(sUnits.contacts) do
table.insert(myTempTable,{name= v.name,guid = v.guid})
end
end
sUnits = nil; --don't need it anymore.

--now process the combined table of units and contacts.
if(#myTempTable > 0) then --if our temptable has more than 0 entries.
local u;
for k,v in pairs(myTempTable) do --loop though selected unit table
u = VP_GetUnit({guid=v.guid}); --get the unit via guid or contact guid. just used for example.
if((u ~=nil) and (u.type=='Ship')) then --only attempt for aircraft or ships.
ScenEdit_SetUnitDamage({guid=u.guid, fires=1, flood=1})
else
print("No Unit selected");
end
end
u = nil; --clear before iterate
end --end for
myTempTable = nil;

I left the notes made by KH in.
Best regards GJ




KnightHawk75 -> RE: Selected Unit (?contact) Damaged (1/18/2022 9:06:23 PM)

Do you want is asked per-selected-unit

or

one firelevel used for the whole selection.

See attached (tested).




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.578125