technic/tree_tap.lua

50 lines
2.2 KiB
Lua
Raw Normal View History

2012-09-22 05:34:33 +02:00
minetest.register_tool("technic:treetap", {
description = "Tree Tap",
inventory_image = "technic_tree_tap.png",
on_use = function(itemstack,user,pointed_thing)
if pointed_thing.type~="node" then return end
2012-09-23 22:58:20 +02:00
if user:get_inventory():room_for_item("main",ItemStack("technic:caouthouc")) then
2012-09-22 05:34:33 +02:00
local pos=minetest.get_pointed_thing_position(pointed_thing,above)
local node=minetest.env:get_node(pos)
local node_name=node.name
2012-10-06 01:36:41 +02:00
if node_name == "technic:rubber_tree_full" then
2012-09-23 22:58:20 +02:00
user:get_inventory():add_item("main",ItemStack("technic:caouthouc"))
2012-09-22 05:34:33 +02:00
minetest.env:set_node(pos,node)
local item=itemstack:to_table()
local item_wear=tonumber((item["wear"]))
item_wear=item_wear+819
if item_wear>65535 then itemstack:clear() return itemstack end
item["wear"]=tostring(item_wear)
itemstack:replace(item)
return itemstack
else
return itemstack
end
else return end
end,
})
minetest.register_craft({
output = "technic:treetap",
recipe = {
{"pipeworks:tube", "default:wood", "default:stick"},
{"", "default:stick", "default:stick"}
},
})
2012-09-23 22:58:20 +02:00
minetest.register_craftitem("technic:caouthouc", {
description = "Caouthouc",
inventory_image = "technic_caouthouc.png",
2012-09-22 05:34:33 +02:00
})
minetest.register_craft({
type = "cooking",
output = "technic:rubber",
2012-09-23 22:58:20 +02:00
recipe = "technic:caouthouc",
2012-09-22 05:34:33 +02:00
})
minetest.register_craftitem("technic:rubber", {
description = "Rubber Fiber",
inventory_image = "technic_rubber.png",
})