Split this mod between the API and the bows/arrows

Fixes #13
This commit is contained in:
upsilon
2017-07-09 18:52:25 +02:00
parent e9acbfa6d1
commit 3dc99c1fce
3 changed files with 12 additions and 240 deletions

View File

@ -222,12 +222,13 @@ on_throw(pos, hitter)
Unlike on_hit, it is optional.
]]
function throwing.register_arrow(name, def)
if not string.find(name, ":") then
name = throwing.modname..":"..name
end
table.insert(throwing.arrows, name)
local registration_name = name
if name:sub(1,9) == "throwing:" then
registration_name = ":"..name
end
if not def.groups then
def.groups = {}
end
@ -274,9 +275,9 @@ function throwing.register_arrow(name, def)
{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_node(registration_name, def)
minetest.register_entity(name.."_entity", throwing.make_arrow_def{
minetest.register_entity(registration_name.."_entity", throwing.make_arrow_def{
physical = false,
visual = "wielditem",
visual_size = {x = 0.125, y = 0.125},
@ -311,10 +312,6 @@ end
---------- Bows -----------
function throwing.register_bow(name, def)
if not string.find(name, ":") then
name = throwing.modname..":"..name
end
if not def.allow_shot then
def.allow_shot = function(player, itemstack, index)
if index >= player:get_inventory():get_size("main") and not def.throw_itself then
@ -394,6 +391,3 @@ function throwing.register_bow(name, def)
})
end
end
dofile(minetest.get_modpath(throwing.modname).."/registration.lua")