michaelm75au -> RE: Using Lua to Call Specific Mounts (3/4/2017 10:03:21 PM)
|
Simple script. quote:
local unit = ScenEdit_GetUnit({name='mech inf'}) -- list of mounts (with devices present) -- print(unit.mounts) -- loop thru the mounts for k,v in pairs(unit.mounts) do -- v is each mount print('Mount ' .. k);print(v) --loop thru the weapons on the mount for k2,v2 in pairs(v.mount_weapons) do -- find particular weapon and do something to the first found on the mount -- say reduce to 10 loads only if more than that if v2.wpn_dbid == 1695 and v2.wpn_current > 10 then print(v2) local to = v2.wpn_current -10 local a = ScenEdit_AddReloadsToUnit({guid=unit.guid, wpn_dbid=v2.wpn_dbid,mount_guid=v.mount_guid, remove=true, number=to}) print('Mount ' .. k .. 'weapon load changed by ' .. a) break end end end -- refresh unit unit = ScenEdit_GetUnit({name='mech inf'}) print(unit.mounts)
|
|
|
|