Conserve custom definition parameters

This commit is contained in:
upsilon 2017-06-20 17:07:46 +02:00
parent 01c10dff75
commit ccd667f9b7

View File

@ -206,16 +206,33 @@ function throwing.register_arrow(name, def)
table.insert(throwing.arrows, name)
local groups = {dig_immediate = 3}
if def.groups then
for k, v in pairs(def.groups) do
groups[k] = v
if not def.groups then
def.groups = {}
end
if not def.groups.dig_immediate then
def.groups.dig_immediate = 3
end
def.inventory_image = def.tiles[1]
def.on_place = function(itemstack, placer, pointed_thing)
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
local playername = placer:get_player_name()
if not minetest.is_protected(pointed_thing.above, playername) then
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
itemstack:take_item()
return itemstack
else
minetest.log("warning", "Player "..playername.." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.record_protection_violation(pointed_thing.above, playername)
return itemstack
end
else
return itemstack
end
end
minetest.register_node(name, {
drawtype = "nodebox",
paramtype = "light",
node_box = {
def.drawtype = "nodebox"
def.paramtype = "light"
def.node_box = {
type = "fixed",
fixed = {
-- Shaft
@ -234,29 +251,8 @@ function throwing.register_arrow(name, def)
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = def.tiles,
inventory_image = def.tiles[1],
description = def.description,
groups = groups,
on_place = function(itemstack, placer, pointed_thing)
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
local playername = placer:get_player_name()
if not minetest.is_protected(pointed_thing.above, playername) then
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
itemstack:take_item()
return itemstack
else
minetest.log("warning", "Player "..playername.." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.record_protection_violation(pointed_thing.above, playername)
return itemstack
end
else
return itemstack
end
end
})
}
minetest.register_node(name, def)
minetest.register_entity(name.."_entity", {
physical = false,
@ -306,10 +302,9 @@ function throwing.register_bow(name, def)
return throwing.is_arrow(itemstack)
end
end
minetest.register_tool(name, {
description = def.description,
inventory_image = def.texture,
on_use = function(itemstack, user, pointed_thing)
def.inventory_image = def.texture
def.textre = nil
def.on_use = function(itemstack, user, pointed_thing)
if not def.throw_itself and not def.allow_shot(user, user:get_inventory():get_stack("main", user:get_wield_index()+1)) then
return itemstack
end
@ -326,9 +321,8 @@ function throwing.register_bow(name, def)
end)
end
return itemstack
end,
groups = def.groups
})
end
minetest.register_tool(name, def)
if def.itemcraft then
minetest.register_craft({