mirror of
https://github.com/minetest-mods/throwing.git
synced 2024-11-15 15:10:23 +01:00
Conserve custom definition parameters
This commit is contained in:
parent
01c10dff75
commit
ccd667f9b7
130
init.lua
130
init.lua
|
@ -206,57 +206,53 @@ 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
|
|
||||||
groups[k] = v
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
minetest.register_node(name, {
|
if not def.groups.dig_immediate then
|
||||||
drawtype = "nodebox",
|
def.groups.dig_immediate = 3
|
||||||
paramtype = "light",
|
end
|
||||||
node_box = {
|
def.inventory_image = def.tiles[1]
|
||||||
type = "fixed",
|
def.on_place = function(itemstack, placer, pointed_thing)
|
||||||
fixed = {
|
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
|
||||||
-- Shaft
|
local playername = placer:get_player_name()
|
||||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
if not minetest.is_protected(pointed_thing.above, playername) then
|
||||||
-- Spitze
|
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
|
||||||
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
|
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
|
||||||
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
|
itemstack:take_item()
|
||||||
-- Federn
|
return itemstack
|
||||||
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
|
|
||||||
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
|
|
||||||
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
|
|
||||||
{6.5/17, -1.5/17, -1.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},
|
|
||||||
{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},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
end
|
||||||
|
def.drawtype = "nodebox"
|
||||||
|
def.paramtype = "light"
|
||||||
|
def.node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
-- Shaft
|
||||||
|
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||||
|
-- Spitze
|
||||||
|
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
|
||||||
|
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
|
||||||
|
-- Federn
|
||||||
|
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
|
||||||
|
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
|
||||||
|
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
|
||||||
|
{6.5/17, -1.5/17, -1.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},
|
||||||
|
{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},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
minetest.register_node(name, def)
|
||||||
|
|
||||||
minetest.register_entity(name.."_entity", {
|
minetest.register_entity(name.."_entity", {
|
||||||
physical = false,
|
physical = false,
|
||||||
|
@ -306,29 +302,27 @@ 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
|
|
||||||
end
|
|
||||||
if shoot_arrow(itemstack, user, def.throw_itself) then
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:add_wear(65535/30)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if def.throw_itself then
|
|
||||||
-- This is a bug. If we return ItemStack(nil), the player punches the entity,
|
|
||||||
-- and if the entity if a __builtin:item, it gets back to his inventory.
|
|
||||||
minetest.after(0.1, function()
|
|
||||||
user:get_inventory():remove_item("main", itemstack)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
groups = def.groups
|
if shoot_arrow(itemstack, user, def.throw_itself) then
|
||||||
})
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
itemstack:add_wear(65535/30)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if def.throw_itself then
|
||||||
|
-- This is a bug. If we return ItemStack(nil), the player punches the entity,
|
||||||
|
-- and if the entity if a __builtin:item, it gets back to his inventory.
|
||||||
|
minetest.after(0.1, function()
|
||||||
|
user:get_inventory():remove_item("main", itemstack)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
minetest.register_tool(name, def)
|
||||||
|
|
||||||
if def.itemcraft then
|
if def.itemcraft then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user