Maciej Kasatkin
2012-09-12 d041c13ad822e30f7f9b9ed0624511968ce47e04
commit | author | age
0e58a6 1     minetest.register_tool("technic:screwdriver", {
MK 2             description = "Screwdriver",
3             inventory_image = "technic_screwdriver.png",
4             on_use = function(itemstack, user, pointed_thing)
5                     -- Must be pointing to facedir applicable node
6                     if pointed_thing.type~="node" then return end
7             local pos=minetest.get_pointed_thing_position(pointed_thing,above)
8             local node=minetest.env:get_node(pos)
9             local node_name=node.name
10             if node.param2==nil  then return end
11                     print (node_name)
12             -- Get ready to set the param2
13                     local n = node.param2
14                     n = n+1
15                     if n == 4 then n = 0 end
16                     -- hacky_swap_node, unforunatly.
17                     local meta = minetest.env:get_meta(pos)
18                     local meta0 = meta:to_table()
19                     node.param2 = n
20                     print(node_name)
21             minetest.env:set_node(pos,node)
22                     meta = minetest.env:get_meta(pos)
23                     meta:from_table(meta0)
d041c1 24             local item=itemstack:to_table()
MK 25             local item_wear=tonumber((item["wear"])) 
26             item_wear=item_wear+819
27             if item_wear>65535 then itemstack:clear() return itemstack end
28             item["wear"]=tostring(item_wear)
29             itemstack:replace(item)
30             return itemstack
31         end,
0e58a6 32     })
MK 33      
34     minetest.register_craft({
35             output = "technic:screwdriver",
36             recipe = {
37                     {"technic:stainless_steel_ingot"},
38                     {"default:stick"}
39             }
40     })