trying to run the following function:
Code: Select all
function mod_ammo_properties(ammo_name, speed, rn_div, dir_div)
--data validation
local ammo
if data.raw.ammo[ammo_name].ammo_type.action then
ammo = data.raw.ammo[ammo_name].ammo_type.action
else merlib.error("mod_ammo_properties: bad name detected for "..ammo_name) return end
local r,s,d
if speed and type(speed) == "number" then
if not speed == -1 then s = speed end
else merlib.error("mod_ammo_properties: bad speed detected for "..ammo_name) end
if rn_div and type(rn_div) == "number" then
if not rn_div == -1 then r = rn_div end
else merlib.error("mod_ammo_properties: bad range diveation detected for "..ammo_name) end
if dir_div and type(dir_div) == "number" then
if not dir_div == -1 then d = dir_div end
else merlib.error("mod_ammo_properties: bad direction deviation detected for "..ammo_name) end
--begin function
for _, ammo_a in pairs(ammo) do
if not ammo_a.action_delivery[1] then merlib.error("mod_ammo_properties: final check failed for "..ammo_name) return else
if ammo_a.action_delivery[1].direction_deviation then
if d then
ammo_a.action_delivery[1].direction_deviation = d
else merlib.error("mod_ammo_properties: direction mod failed for "..ammo_name) end
end
if ammo_a.action_delivery[1].range_deviation then
if r then
ammo_a.action_delivery[1].range_deviation = r
else merlib.error("mod_ammo_properties: range mod failed for "..ammo_name) end
end
if ammo_a.action_delivery[1].starting_speed then
if v then
ammo_a.action_delivery[1].starting_speed = s
else merlib.error("mod_ammo_properties: speed mod failed for "..ammo_name) end
end
end
end
end
Code: Select all
5.677 Script @__KS-Combat-sniper-fix__/prototypes/ammo.lua:4: KSF: mod_ammo_properties: direction mod failed for firearm-magazine
5.677 Script @__KS-Combat-sniper-fix__/prototypes/ammo.lua:4: KSF: mod_ammo_properties: range mod failed for firearm-magazine
5.677 Script @__KS-Combat-sniper-fix__/prototypes/ammo.lua:4: KSF: mod_ammo_properties: speed mod failed for firearm-magazine
5.677 Script @__KS-Combat-sniper-fix__/prototypes/ammo.lua:4: KSF: mod_ammo_properties: final check failed for piercing-rounds-magazine
5.677 Script @__KS-Combat-sniper-fix__/prototypes/ammo.lua:4: KSF: mod_ammo_properties: final check failed for uranium-rounds-magazine
Code: Select all
local bullet_speed
for _, ammo in pairs(data.raw.ammo["firearm-magazine"].ammo_type.action) do
if ammo.action_delivery[1].starting_speed then
bullet_speed = ammo.action_delivery[1].starting_speed
end
end