Divergent/mods/Weapon Parts Overhaul/gamedata/scripts/mag_support.script

25 lines
740 B
Plaintext

-- mag support wrapper
local function supports_mags(wpn)
if wuut_mags then
local defaultMagSection = wuut_mags.WeaponGetDefaulMagSection(wpn)
local defaultMagSectionExists = system_ini():section_exist(defaultMagSection)
return defaultMagSectionExists
elseif magazines then
return magazine_binder.is_supported_weapon(wpn)
else return false
end
end
function eject_mag(wpn)
if not supports_mags(wpn) then
wpn:force_unload_magazine(true)
return
end
if wuut_mags and wuut_mags.MagazineInWeaponIsValid(wpn) then
return wuut_mags.weapon_eject_mag_functor(wpn)
elseif magazines then
magazines.eject_magazine(wpn)
else wpn:force_unload_magazine(true) end
end