More minor corrections
This commit is contained in:
parent
70dac6ef64
commit
20405958da
2 changed files with 16 additions and 11 deletions
|
@ -155,6 +155,11 @@ Used by `shooter.register_weapon`
|
||||||
description = "My Awesome Gun (Unloaded)",
|
description = "My Awesome Gun (Unloaded)",
|
||||||
inventory_image = "my_awesome_gun_unloaded.png",
|
inventory_image = "my_awesome_gun_unloaded.png",
|
||||||
},
|
},
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
-- Called before the built-in tool `one_use` handler
|
||||||
|
-- Should return a valid `ItemStack` or `nil` to cancel the shot
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
on_hit = function(pointed_thing, spec, dir)
|
on_hit = function(pointed_thing, spec, dir)
|
||||||
-- May be used for arbitary shot effects like knock-back, etc.
|
-- May be used for arbitary shot effects like knock-back, etc.
|
||||||
-- Return `true` to override built-in damage effects
|
-- Return `true` to override built-in damage effects
|
||||||
|
|
|
@ -59,7 +59,6 @@ local config = shooter.config
|
||||||
local server_step = minetest.settings:get("dedicated_server_step")
|
local server_step = minetest.settings:get("dedicated_server_step")
|
||||||
|
|
||||||
shooter.register_weapon = function(name, def)
|
shooter.register_weapon = function(name, def)
|
||||||
shooter.registered_weapons[name] = def
|
|
||||||
-- Fix definition table
|
-- Fix definition table
|
||||||
def.sounds = def.sounds or {}
|
def.sounds = def.sounds or {}
|
||||||
def.sounds.reload = def.sounds.reload or "shooter_reload"
|
def.sounds.reload = def.sounds.reload or "shooter_reload"
|
||||||
|
@ -73,6 +72,7 @@ shooter.register_weapon = function(name, def)
|
||||||
description = def.description.." (unloaded)",
|
description = def.description.." (unloaded)",
|
||||||
inventory_image = def.inventory_image,
|
inventory_image = def.inventory_image,
|
||||||
}
|
}
|
||||||
|
shooter.registered_weapons[name] = table.copy(def)
|
||||||
-- Register loaded item tool
|
-- Register loaded item tool
|
||||||
minetest.register_tool(name.."_loaded", {
|
minetest.register_tool(name.."_loaded", {
|
||||||
description = def.description,
|
description = def.description,
|
||||||
|
@ -81,6 +81,7 @@ shooter.register_weapon = function(name, def)
|
||||||
if type(def.on_use) == "function" then
|
if type(def.on_use) == "function" then
|
||||||
itemstack = def.on_use(itemstack, user, pointed_thing)
|
itemstack = def.on_use(itemstack, user, pointed_thing)
|
||||||
end
|
end
|
||||||
|
if itemstack then
|
||||||
local spec = table.copy(def.spec)
|
local spec = table.copy(def.spec)
|
||||||
if shooter.fire_weapon(user, itemstack, spec) then
|
if shooter.fire_weapon(user, itemstack, spec) then
|
||||||
itemstack:add_wear(def.spec.wear)
|
itemstack:add_wear(def.spec.wear)
|
||||||
|
@ -88,6 +89,7 @@ shooter.register_weapon = function(name, def)
|
||||||
itemstack:replace(def.unloaded_item.name)
|
itemstack:replace(def.unloaded_item.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_hit = def.on_hit,
|
on_hit = def.on_hit,
|
||||||
|
@ -175,6 +177,9 @@ shooter.is_valid_object = function(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
shooter.punch_node = function(pos, spec)
|
shooter.punch_node = function(pos, spec)
|
||||||
|
if config.enable_protection and minetest.is_protected(pos, spec.user) then
|
||||||
|
return
|
||||||
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then
|
if not node then
|
||||||
return
|
return
|
||||||
|
@ -183,11 +188,6 @@ shooter.punch_node = function(pos, spec)
|
||||||
if not item then
|
if not item then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if config.enable_protection then
|
|
||||||
if minetest.is_protected(pos, spec.user) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if item.groups then
|
if item.groups then
|
||||||
for k, v in pairs(spec.groups) do
|
for k, v in pairs(spec.groups) do
|
||||||
local level = item.groups[k] or 0
|
local level = item.groups[k] or 0
|
||||||
|
|
Loading…
Reference in a new issue