gates.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. local gate_list = {}
  2. minetest.register_node("potions:gate_horizon", {
  3. description = "Gate Horizon",
  4. drawtype = "nodebox",
  5. paramtype = "light",
  6. is_ground_content = false,
  7. sunlight_propagates = true,
  8. paramtype2 = "facedir",
  9. tiles = {
  10. {
  11. name = "default_water_source_animated.png^[colorize:purple:180",
  12. backface_culling = false,
  13. animation = {
  14. type = "vertical_frames",
  15. aspect_w = 16,
  16. aspect_h = 16,
  17. length = 2.0,
  18. },
  19. },
  20. {
  21. name = "default_water_source_animated.png^[colorize:purple:180",
  22. backface_culling = true,
  23. animation = {
  24. type = "vertical_frames",
  25. aspect_w = 16,
  26. aspect_h = 16,
  27. length = 2.0,
  28. },
  29. },
  30. },
  31. groups = {cracky=3},
  32. alpha = 160,
  33. -- pointable = false,
  34. walkable = false,
  35. post_effect_color = {a = 103, r = 160, g = 60, b = 190},
  36. sounds = default.node_sound_water_defaults(),
  37. -- drop = "xpanes:" .. name .. "_flat",
  38. node_box = {
  39. type = "fixed",
  40. fixed = {{-3/2, -3/2, -1/32, 3/2, 3/2, 1/32}},
  41. },
  42. selection_box = {
  43. type = "fixed",
  44. fixed = {{-3/2, -3/2, -1/32, 3/2, 3/2, 1/32}},
  45. },
  46. on_timer = function (pos, elapsed)
  47. local node = minetest.get_node(pos)
  48. local objs = minetest.get_objects_inside_radius(pos, 2)
  49. for k, obj in pairs(objs) do
  50. if obj:is_player() then
  51. local objpos = obj:getpos()
  52. if #gate_list > 0 then
  53. local p = gate_list[math.random(#gate_list)]
  54. obj:setpos(p)
  55. end
  56. print("player in gate")
  57. end
  58. end
  59. return true
  60. end,
  61. on_construct = function(pos)
  62. minetest.get_node_timer(pos):start(3)
  63. end,
  64. })
  65. local function check_gate(pos)
  66. local function is_gate_node(p)
  67. local n = minetest.get_node(p)
  68. return n.name == "potions:gateblock"
  69. end
  70. if not is_gate_node({x=pos.x, y=pos.y, z=pos.z}) then return false end
  71. if not is_gate_node({x=pos.x+1, y=pos.y, z=pos.z}) then return false end
  72. if not is_gate_node({x=pos.x-1, y=pos.y, z=pos.z}) then return false end
  73. if not is_gate_node({x=pos.x, y=pos.y+4, z=pos.z}) then return false end
  74. if not is_gate_node({x=pos.x+1, y=pos.y+4, z=pos.z}) then return false end
  75. if not is_gate_node({x=pos.x-1, y=pos.y+4, z=pos.z}) then return false end
  76. if not is_gate_node({x=pos.x-2, y=pos.y+1, z=pos.z}) then return false end
  77. if not is_gate_node({x=pos.x-2, y=pos.y+2, z=pos.z}) then return false end
  78. if not is_gate_node({x=pos.x-2, y=pos.y+3, z=pos.z}) then return false end
  79. if not is_gate_node({x=pos.x+2, y=pos.y+1, z=pos.z}) then return false end
  80. if not is_gate_node({x=pos.x+2, y=pos.y+2, z=pos.z}) then return false end
  81. if not is_gate_node({x=pos.x+2, y=pos.y+3, z=pos.z}) then return false end
  82. local center = {x=pos.x, y=pos.y + 2, z=pos.z}
  83. minetest.set_node(center, {name="potions:gate_horizon"})
  84. table.insert(gate_list, center);
  85. --[[
  86. minetest.add_particlespawner({
  87. amount = 200,
  88. time = 2,
  89. minpos = pos,
  90. maxpos = pos,
  91. minvel = {x=-0.1, y=2.6, z=-0.1},
  92. maxvel = {x=0.1, y=3.6, z=0.1},
  93. minacc = {x=-0.1, y=.1, z=-0.1},
  94. maxacc = {x=0.1, y=.1, z=0.1},
  95. minexptime = 2.5,
  96. maxexptime = 4.5,
  97. minsize = 4.2,
  98. maxsize = 5.2,
  99. texture = "tnt_smoke.png",
  100. })
  101. ]]
  102. return true
  103. end
  104. minetest.register_node("potions:gateblock", {
  105. description = "Gate Block",
  106. drawtype = "node",
  107. tiles = {"default_obsidian.png^[colorize:white:30"},
  108. groups = {cracky=3,},
  109. on_construct = check_gate,
  110. })