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) table.insert(throwing.arrows, name)
local groups = {dig_immediate = 3} if not def.groups then
if def.groups then def.groups = {}
for k, v in pairs(def.groups) do end
groups[k] = v 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
end end
minetest.register_node(name, { def.drawtype = "nodebox"
drawtype = "nodebox", def.paramtype = "light"
paramtype = "light", def.node_box = {
node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
-- Shaft -- 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}, {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}, {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
} }
}, }
tiles = def.tiles, minetest.register_node(name, def)
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_entity(name.."_entity", { minetest.register_entity(name.."_entity", {
physical = false, physical = false,
@ -306,10 +302,9 @@ function throwing.register_bow(name, def)
return throwing.is_arrow(itemstack) return throwing.is_arrow(itemstack)
end end
end end
minetest.register_tool(name, { def.inventory_image = def.texture
description = def.description, def.textre = nil
inventory_image = def.texture, def.on_use = function(itemstack, user, pointed_thing)
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 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 return itemstack
end end
@ -326,9 +321,8 @@ function throwing.register_bow(name, def)
end) end)
end end
return itemstack return itemstack
end, end
groups = def.groups minetest.register_tool(name, def)
})
if def.itemcraft then if def.itemcraft then
minetest.register_craft({ minetest.register_craft({