Pipeworks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
2.1 KiB

  1. local S = minetest.get_translator("pipeworks")
  2. if not minetest.get_modpath("auto_tree_tap") and
  3. minetest.get_modpath("technic") then
  4. minetest.register_abm({
  5. nodenames = { "auto_tree_tap:off", "auto_tree_tap:on" },
  6. chance = 1,
  7. interval = 1,
  8. action = function(pos, node, active_object_count, active_object_count_wider)
  9. local fdir = node.param2
  10. local meta = minetest.get_meta(pos)
  11. local inv = meta:get_inventory()
  12. inv:set_size("pick", 1)
  13. inv:set_size("ghost_pick", 1)
  14. inv:set_size("main", 100)
  15. minetest.set_node(pos, {name = "pipeworks:nodebreaker_off", param2 = fdir})
  16. minetest.registered_nodes["pipeworks:nodebreaker_off"].on_punch(pos, node)
  17. inv:set_stack("pick", 1, ItemStack("technic:treetap"))
  18. end
  19. })
  20. minetest.register_node(":auto_tree_tap:off", {
  21. description = S("Auto-Tap"),
  22. tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
  23. "pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
  24. is_ground_content = true,
  25. paramtype2 = "facedir",
  26. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 },
  27. sounds = default.node_sound_stone_defaults(),
  28. tube = {connect_sides={back=1}},
  29. on_construct = function(pos)
  30. local meta = minetest.get_meta(pos)
  31. local inv = meta:get_inventory()
  32. inv:set_size("pick", 1)
  33. inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
  34. end,
  35. after_place_node = function (pos, placer)
  36. pipeworks.scan_for_tube_objects(pos, placer)
  37. local placer_pos = placer:get_pos()
  38. --correct for the player's height
  39. if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
  40. --correct for 6d facedir
  41. if placer_pos then
  42. local dir = {
  43. x = pos.x - placer_pos.x,
  44. y = pos.y - placer_pos.y,
  45. z = pos.z - placer_pos.z
  46. }
  47. local node = minetest.get_node(pos)
  48. node.param2 = minetest.dir_to_facedir(dir, true)
  49. minetest.set_node(pos, node)
  50. minetest.log("action", "real (6d) facedir: " .. node.param2)
  51. end
  52. end,
  53. after_dig_node = pipeworks.scan_for_tube_objects,
  54. })
  55. end