techpack/gravelsieve/hammer.lua

61 lines
1.3 KiB
Lua
Raw Normal View History

2018-03-10 22:14:57 +01:00
--[[
Gravel Sieve Mod
================
]]--
-- Load support for I18n
local S = gravelsieve.S
2018-03-10 22:14:57 +01:00
gravelsieve.disallow = function(pos, node, user, mode, new_param2)
return false
end
gravelsieve.handler = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
local pos = pointed_thing.under
if minetest.is_protected(pos, user:get_player_name()) then
minetest.record_protection_violation(pos, user:get_player_name())
return
end
local node = minetest.get_node(pos)
if node.name == "default:cobble" or node.name == "default:mossycobble"
or node.name == "default:desert_cobble" then
node.name = "default:gravel"
minetest.swap_node(pos, node)
minetest.sound_play({
name="default_dig_crumbly"},{
gain=1,
pos=pos,
max_hear_distance=6,
loop=false})
end
2018-12-22 16:58:11 +01:00
itemstack:add_wear(65535 / (500 - 1))
2018-03-10 22:14:57 +01:00
return itemstack
end
minetest.register_tool("gravelsieve:hammer", {
description = S("Hammer converts Cobblestone into Gravel"),
2018-03-10 22:14:57 +01:00
inventory_image = "gravelsieve_hammer.png",
on_use = function(itemstack, user, pointed_thing)
2018-12-22 16:58:11 +01:00
return gravelsieve.handler(itemstack, user, pointed_thing)
2018-03-10 22:14:57 +01:00
end,
})
minetest.register_craft({
output = "gravelsieve:hammer",
recipe = {
{"", "default:steel_ingot", ""},
{"", "group:stick", "default:steel_ingot"},
{"group:stick", "", ""},
}
})