junction.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --[[
  2. Hyperloop Mod
  3. =============
  4. Copyright (C) 2017-2019 Joachim Stolberg
  5. LGPLv2.1+
  6. See LICENSE.txt for more information
  7. ]]--
  8. -- for lazy programmers
  9. local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
  10. local P = minetest.string_to_pos
  11. local M = minetest.get_meta
  12. -- Load support for intllib.
  13. local S = vents.S
  14. local NS = vents.NS
  15. local Tube = vents.Tube
  16. local Stations = vents.Stations
  17. Tube:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
  18. if node.name == "vents:station" then
  19. if out_dir <= 5 then
  20. Stations:update_connections(pos, out_dir, peer_pos)
  21. local s = vents.get_connection_string(pos)
  22. M(pos):set_string("infotext", S("Station connected to ")..s)
  23. end
  24. elseif node.name == "vents:junction" then
  25. Stations:update_connections(pos, out_dir, peer_pos)
  26. local s = vents.get_connection_string(pos)
  27. M(pos):set_string("infotext", S("Junction connected to ")..s)
  28. elseif Tube.secondary_node_names[node.name] then
  29. if out_dir == 5 then
  30. Stations:update_connections(pos, out_dir, peer_pos)
  31. local s = vents.get_connection_string(pos)
  32. M(pos):set_string("conn_to", s)
  33. end
  34. end
  35. end)
  36. minetest.register_node("vents:junction", {
  37. description = S("Vent Junction"),
  38. tiles = {"vents_station_connection.png"},
  39. after_place_node = function(pos, placer, itemstack, pointed_thing)
  40. vents.check_network_level(pos, placer)
  41. M(pos):set_string("infotext", S("Junction"))
  42. Stations:set(pos, "Junction", {
  43. owner = placer:get_player_name(), junction = true})
  44. Tube:after_place_node(pos)
  45. end,
  46. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  47. Tube:after_dig_node(pos)
  48. Stations:delete(pos)
  49. end,
  50. paramtype2 = "facedir",
  51. on_rotate = screwdriver.disallow,
  52. paramtype = "light",
  53. groups = {breakable=1},
  54. is_ground_content = false,
  55. sounds = {footstep = {name = 'metal', gain = 1}},
  56. })