60 lines
1.9 KiB
Lua
60 lines
1.9 KiB
Lua
-- tools.lua: Tool definitions
|
|
-- Copyright (c) 2015 Calinou
|
|
-- CC0 1.0 Universal
|
|
|
|
minetest.register_tool("axinite:tool", {
|
|
description = "Staff tool",
|
|
inventory_image = "staff_tool.png",
|
|
range = 15,
|
|
tool_capabilities = {
|
|
full_punch_interval = 0.0,
|
|
max_drop_level = 3,
|
|
groupcaps = {
|
|
cracky = {times = {[1] = 0.0, [2] = 0.0, [3] = 0.0}, uses = 0, maxlevel = 3},
|
|
crumbly = {times = {[1] = 0.0, [2] = 0.0, [3] = 0.0}, uses = 0, maxlevel = 3},
|
|
choppy= {times = {[1] = 0.0, [2] = 0.0, [3] = 0.0}, uses = 0, maxlevel = 3},
|
|
},
|
|
damage_groups = {fleshy = 1},
|
|
},
|
|
})
|
|
|
|
-- Flint and steel
|
|
|
|
minetest.override_item("fire:flint_and_steel", {
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local sound_pos = pointed_thing.above or user:get_pos()
|
|
minetest.sound_play(
|
|
"fire_flint_and_steel",
|
|
{pos = sound_pos, gain = 0.5, max_hear_distance = 8}
|
|
)
|
|
local player_name = user:get_player_name()
|
|
if pointed_thing.type == "node" then
|
|
local node_under = minetest.get_node(pointed_thing.under).name
|
|
local nodedef = minetest.registered_nodes[node_under]
|
|
if not nodedef then
|
|
return
|
|
end
|
|
if minetest.is_protected(pointed_thing.under, player_name) then
|
|
minetest.chat_send_player(player_name, "This area is protected")
|
|
return
|
|
end
|
|
if nodedef.on_ignite then
|
|
nodedef.on_ignite(pointed_thing.under, user)
|
|
elseif minetest.get_item_group(node_under, "flammable") >= 1
|
|
and minetest.get_node(pointed_thing.above).name == "air" then
|
|
minetest.set_node(pointed_thing.above, {name = "axinite:flame"})
|
|
end
|
|
end
|
|
if not (creative and creative.is_enabled_for
|
|
and creative.is_enabled_for(player_name)) then
|
|
-- Wear tool
|
|
local wdef = itemstack:get_definition()
|
|
itemstack:add_wear(1000)
|
|
-- Tool break sound
|
|
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
|
minetest.sound_play(wdef.sound.breaks, {pos = sound_pos, gain = 0.5})
|
|
end
|
|
return itemstack
|
|
end
|
|
end
|
|
}) |