Maciej Kasatkin
2012-09-12 14506c477ac69150fd37c80e1571e80fc0ce34fc
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
1590dd 11                  -- Get ready to set the param2
0e58a6 12                     local n = node.param2
MK 13                     n = n+1
14                     if n == 4 then n = 0 end
15                     -- hacky_swap_node, unforunatly.
16                     local meta = minetest.env:get_meta(pos)
17                     local meta0 = meta:to_table()
18                     node.param2 = n
1590dd 19                    minetest.env:set_node(pos,node)
0e58a6 20                     meta = minetest.env:get_meta(pos)
MK 21                     meta:from_table(meta0)
d041c1 22             local item=itemstack:to_table()
MK 23             local item_wear=tonumber((item["wear"])) 
24             item_wear=item_wear+819
25             if item_wear>65535 then itemstack:clear() return itemstack end
26             item["wear"]=tostring(item_wear)
27             itemstack:replace(item)
28             return itemstack
29         end,
0e58a6 30     })
MK 31      
32     minetest.register_craft({
33             output = "technic:screwdriver",
34             recipe = {
35                     {"technic:stainless_steel_ingot"},
36                     {"default:stick"}
37             }
38     })