spears/tools.lua

99 lines
3.3 KiB
Lua
Raw Normal View History

2024-01-03 22:13:14 +01:00
local S = minetest.get_translator("spears")
2020-04-18 15:31:17 +02:00
function spears_register_spear(spear_type, desc, base_damage, toughness, material)
2015-10-03 20:45:32 +02:00
2020-04-18 15:31:17 +02:00
minetest.register_tool("spears:spear_" .. spear_type, {
2024-01-03 22:13:14 +01:00
description = desc,
2020-04-20 23:50:20 +02:00
wield_image = "spears_spear_" .. spear_type .. ".png^[transform4",
inventory_image = "spears_spear_" .. spear_type .. ".png",
2020-04-19 22:06:25 +02:00
wield_scale= {x = 1.5, y = 1.5, z = 1.5},
2020-04-18 15:31:17 +02:00
on_secondary_use = function(itemstack, user, pointed_thing)
2020-04-19 18:50:54 +02:00
spears_throw(itemstack, user, pointed_thing)
2022-09-28 23:44:35 +02:00
if not minetest.settings:get_bool("creative_mode") then
2015-10-03 20:45:32 +02:00
itemstack:take_item()
end
return itemstack
end,
2020-04-19 11:55:40 +02:00
on_place = function(itemstack, user, pointed_thing)
2020-04-19 18:50:54 +02:00
spears_throw(itemstack, user, pointed_thing)
2022-09-28 23:44:35 +02:00
if not minetest.settings:get_bool("creative_mode") then
2020-04-19 11:55:40 +02:00
itemstack:take_item()
end
return itemstack
end,
2015-10-03 20:45:32 +02:00
tool_capabilities = {
full_punch_interval = 1.5,
max_drop_level=1,
groupcaps={
cracky = {times={[3]=2}, uses=toughness, maxlevel=1},
},
2020-04-18 15:31:17 +02:00
damage_groups = {fleshy=base_damage},
2020-04-19 11:55:40 +02:00
},
sound = {breaks = "default_tool_breaks"},
groups = {flammable = 1}
2015-10-03 20:45:32 +02:00
})
2020-04-19 11:55:40 +02:00
local SPEAR_ENTITY = spears_set_entity(spear_type, base_damage, toughness)
2015-10-03 20:45:32 +02:00
2020-04-18 15:31:17 +02:00
minetest.register_entity("spears:spear_" .. spear_type .. "_entity", SPEAR_ENTITY)
2015-10-03 20:45:32 +02:00
minetest.register_craft({
2020-04-18 15:31:17 +02:00
output = 'spears:spear_' .. spear_type,
2015-10-03 20:45:32 +02:00
recipe = {
2022-09-28 23:44:35 +02:00
{"", "", material},
{"", "group:stick", ""},
{"group:stick", "", ""}
2015-10-03 20:45:32 +02:00
}
})
minetest.register_craft({
2020-04-18 15:31:17 +02:00
output = 'spears:spear_' .. spear_type,
2015-10-03 20:45:32 +02:00
recipe = {
2022-09-28 23:44:35 +02:00
{material, "", ""},
{"", "group:stick", ""},
{"", "", "group:stick"}
2015-10-03 20:45:32 +02:00
}
})
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_stone_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('stone', S('Stone Spear'), 4, 20, 'group:stone')
2015-10-03 20:45:32 +02:00
end
2022-10-12 23:51:07 +02:00
if minetest.get_modpath("pigiron") then
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_iron_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('iron', S('Iron Spear'), 5.5, 30, 'pigiron:iron_ingot')
2022-10-12 23:51:07 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_steel_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('steel', S('Steel Spear'), 6, 35, 'default:steel_ingot')
2022-10-12 23:51:07 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_copper_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('copper', S('Copper Spear'), 4.8, 30, 'default:copper_ingot')
2022-10-12 23:51:07 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_bronze_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('bronze', S('Bronze Spear'), 5.5, 35, 'default:bronze_ingot')
2022-10-12 23:51:07 +02:00
end
else
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_steel_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('steel', S('Steel Spear'), 6, 30, 'default:steel_ingot')
2022-10-12 23:51:07 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_copper_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('copper', S('Copper Spear'), 5, 30, 'default:copper_ingot')
2022-10-12 23:51:07 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_bronze_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('bronze', S('Bronze Spear'), 6, 35, 'default:bronze_ingot')
2022-10-12 23:51:07 +02:00
end
2015-10-03 20:45:32 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_obsidian_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('obsidian', S('Obsidian Spear'), 8, 30, 'default:obsidian')
2015-10-03 20:45:32 +02:00
end
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_diamond_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('diamond', S('Diamond Spear'), 8, 40, 'default:diamond')
2015-10-03 20:45:32 +02:00
end
2020-04-19 21:53:10 +02:00
2024-02-03 10:56:25 +01:00
if minetest.settings:get_bool('spears_enable_gold_spear') then
2024-02-04 19:05:01 +01:00
spears_register_spear('gold', S('Golden Spear'), 5, 40, 'default:gold_ingot')
2020-04-19 21:53:10 +02:00
end