spears/tools.lua

74 lines
1.9 KiB
Lua
Raw Normal View History

2015-10-16 20:09:26 +02:00
function spears_register_spear(kind, desc, eq, toughness, material)
2015-10-03 20:45:32 +02:00
minetest.register_tool("spears:spear_" .. kind, {
description = desc .. " spear",
2016-01-06 22:05:49 +01:00
wield_image = "spears_spear_" .. kind .. ".png",
inventory_image = "spears_spear_" .. kind .. ".png^[transform4",
2015-10-03 20:45:32 +02:00
wield_scale= {x=2,y=1,z=1},
on_drop = function(itemstack, user, pointed_thing)
spears_shot(itemstack, user)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end,
on_place = function(itemstack, user, pointed_thing)
minetest.add_item(pointed_thing.above, itemstack)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end,
tool_capabilities = {
full_punch_interval = 1.5,
max_drop_level=1,
groupcaps={
cracky = {times={[3]=2}, uses=toughness, maxlevel=1},
},
damage_groups = {fleshy=eq},
}
})
2015-10-16 20:09:26 +02:00
SPEAR_ENTITY=spears_set_entity(kind, eq, toughness)
2015-10-03 20:45:32 +02:00
minetest.register_entity("spears:spear_" .. kind .. "_entity", SPEAR_ENTITY)
minetest.register_craft({
2015-10-16 20:09:26 +02:00
output = 'spears:spear_' .. kind,
2015-10-03 20:45:32 +02:00
recipe = {
2015-10-16 20:09:26 +02:00
{'group:wood', 'group:wood', material},
2015-10-03 20:45:32 +02:00
}
})
minetest.register_craft({
2015-10-16 20:09:26 +02:00
output = 'spears:spear_' .. kind,
2015-10-03 20:45:32 +02:00
recipe = {
2015-10-16 20:09:26 +02:00
{material, 'group:wood', 'group:wood'},
2015-10-03 20:45:32 +02:00
}
})
end
if not DISABLE_STONE_SPEAR then
spears_register_spear('stone', 'Stone', 4, 20, 'group:stone')
end
if not DISABLE_STEEL_SPEAR then
spears_register_spear('steel', 'Steel', 6, 30, 'default:steel_ingot')
end
2016-01-06 22:05:49 +01:00
if not DISABLE_COPPER_SPEAR then
spears_register_spear('copper', 'Copper', 5, 35, 'default:copper_ingot')
end
if not DISABLE_BRONZE_SPEAR then
spears_register_spear('bronze', 'Bronze', 6, 35, 'default:bronze_ingot')
end
2015-10-03 20:45:32 +02:00
if not DISABLE_OBSIDIAN_SPEAR then
spears_register_spear('obsidian', 'Obsidian', 8, 30, 'default:obsidian')
end
if not DISABLE_DIAMOND_SPEAR then
spears_register_spear('diamond', 'Diamond', 8, 40, 'default:diamond')
end