Advertisement
Guest User

Untitled

a guest
Sep 11th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. minetest.register_tool("technic:screwdriver", {
  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(dump(pos..","..node_name))
  21. minetest.env:set_node(pos,node_name)
  22. meta = minetest.env:get_meta(pos)
  23. meta:from_table(meta0)
  24. -- appropriatly set the wear of the screwdriver
  25. m = itemstack:get_wear()
  26. if m == 0 then m = 65535 end
  27. m = m-6554
  28. return {wear=m}
  29. end,
  30. })
  31.  
  32. minetest.register_craft({
  33. output = "technic:screwdriver",
  34. recipe = {
  35. {"technic:stainless_steel_ingot"},
  36. {"default:stick"}
  37. }
  38. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement