stripped_tree/init.lua

71 lines
1.7 KiB
Lua
Raw Normal View History

2020-11-04 00:08:38 +01:00
--Register nodes
local trunk_names = {
"tree", "jungletree", "aspen_tree", "acacia_tree","pine_tree",
}
2020-11-05 01:34:39 +01:00
-- Register all stripped trees
2020-11-04 00:08:38 +01:00
for _, name in ipairs(trunk_names) do
minetest.register_node(":default:stripped_"..name, {
description = "Stripped "..name,
tiles = {
"stripped_"..name.."_top.png",
"stripped_"..name.."_top.png",
"stripped_"..name..".png"
},
2020-11-05 01:34:39 +01:00
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
2020-11-04 00:08:38 +01:00
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
on_place = minetest.rotate_node,
})
end
--Register tool
minetest.register_tool("chisel_tree:chisel", {
description = "A chisel for wood",
inventory_image = "chisel.png",
wield_image = "chisel.png",
sound = {breaks = "default_tool_breaks"},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
local pos = pointed_thing.under
local pname = user:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
local node = minetest.get_node(pos).name
for _, n in ipairs(trunk_names) do
local tree = "default:"..n
if tree==node then
2020-11-05 01:55:15 +01:00
local old_node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "default:stripped_"..n, param2 = old_node.param2})
2020-11-04 00:08:38 +01:00
itemstack:add_wear(65535 / 299) -- 300 uses
return itemstack
end
end
end,
})
2020-11-04 00:25:04 +01:00
--Register craft
minetest.register_craft({
output = "chisel_tree:chisel",
recipe = {
{"", "default:steel_ingot", ""},
{"", "group:fence", ""},
}
})
2020-11-04 00:08:38 +01:00