Make get_weapon_spec a little more robust

This commit is contained in:
stujones11 2019-03-26 18:41:29 +00:00
parent 35ddb6c038
commit 4d8aa37f72

View file

@ -83,7 +83,8 @@ shooter.register_weapon = function(name, def)
itemstack = def.on_use(itemstack, user, pointed_thing)
end
if itemstack then
local spec = shooter.get_weapon_spec(nil, name)
local spec = shooter.get_weapon_spec(nil, name) or
table.copy(def.spec)
if shooter.fire_weapon(user, itemstack, spec) then
itemstack:add_wear(def.spec.wear)
if itemstack:get_count() == 0 then
@ -120,10 +121,9 @@ end
shooter.get_weapon_spec = function(_, name)
local def = shooter.registered_weapons[name]
if not def then
return nil
if def then
return table.copy(def.spec)
end
return table.copy(def.spec)
end
shooter.get_configuration = function(conf)