init.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. minetest.register_node("my_garage_door:garage_door", {
  2. description = "Garage Door",
  3. tiles = {
  4. "default_snow.png"
  5. },
  6. drawtype = "nodebox",
  7. paramtype = "light",
  8. paramtype2 = "facedir",
  9. groups = {cracky=3},
  10. node_box = {
  11. type = "fixed",
  12. fixed = {
  13. {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
  14. {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
  15. {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
  16. {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
  17. {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
  18. }
  19. },
  20. selection_box = {
  21. type = "fixed",
  22. fixed = {
  23. {-1.5, -0.5, -0.1875, 1.5, 1.5, -0.0625},
  24. }
  25. },
  26. on_place = function(itemstack, placer, pointed_thing)
  27. local p = pointed_thing.above
  28. local p2 = minetest.dir_to_facedir(placer:get_look_dir())
  29. print(p2)
  30. minetest.set_node(p, {name = "my_garage_door:garage_door",param2 = p2})
  31. minetest.set_node({x=p.x,y=p.y+1,z=p.z}, {name = "my_garage_door:garage_door_top",param2 = p2})
  32. end,
  33. after_destruct = function(pos, oldnode)
  34. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "air"})
  35. end,
  36. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  37. local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir())
  38. local t1 = {x=pos.x,y=pos.y+1,z=pos.z}
  39. local t2 = {x=pos.x,y=pos.y+1,z=pos.z}
  40. if p2 == 0 then
  41. t1 = {x=pos.x,y=pos.y+1,z=pos.z+1}
  42. t2 = {x=pos.x,y=pos.y+1,z=pos.z+2}
  43. elseif p2 == 1 then
  44. t1 = {x=pos.x+1,y=pos.y+1,z=pos.z}
  45. t2 = {x=pos.x+2,y=pos.y+1,z=pos.z}
  46. elseif p2 == 2 then
  47. t1 = {x=pos.x,y=pos.y+1,z=pos.z-1}
  48. t2 = {x=pos.x,y=pos.y+1,z=pos.z-2}
  49. elseif p2 == 3 then
  50. t1 = {x=pos.x-1,y=pos.y+1,z=pos.z}
  51. t2 = {x=pos.x-2,y=pos.y+1,z=pos.z}
  52. end
  53. minetest.set_node(t1,{name="my_garage_door:garage_door_open",param2=p2})
  54. minetest.set_node(t2,{name="my_garage_door:garage_door_open2",param2=p2})
  55. minetest.set_node(pos,{name="air"})
  56. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
  57. --end
  58. end,
  59. })
  60. minetest.register_node("my_garage_door:garage_door_top", {
  61. tiles = {
  62. "default_snow.png"
  63. },
  64. drawtype = "nodebox",
  65. paramtype = "light",
  66. paramtype2= "facedir",
  67. drop = "",
  68. diggable = false,
  69. pointable = false,
  70. groups = {cracky=3},
  71. node_box = {
  72. type = "fixed",
  73. fixed = {
  74. {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
  75. {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
  76. {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
  77. {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
  78. {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
  79. }
  80. },
  81. selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
  82. })
  83. minetest.register_node("my_garage_door:garage_door_open", {
  84. tiles = {
  85. "default_snow.png"
  86. },
  87. drawtype = "nodebox",
  88. paramtype = "light",
  89. paramtype2= "facedir",
  90. drop = "my_garage_door:garage_door",
  91. diggable = false,
  92. groups = {cracky=3},
  93. node_box = {
  94. type = "fixed",
  95. fixed = {
  96. {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
  97. {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
  98. {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
  99. {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
  100. {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
  101. }
  102. },
  103. selection_box = {type = "fixed",fixed = {{-1.5, 0.375, -0.5, 1.5, 0.5, 1.5},}},
  104. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  105. local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir())
  106. local t1 = {x=pos.x,y=pos.y+1,z=pos.z}
  107. local t2 = {x=pos.x,y=pos.y+1,z=pos.z}
  108. local t3
  109. if p2 == 0 then
  110. t1 = {x=pos.x,y=pos.y,z=pos.z-1}
  111. t2 = {x=pos.x,y=pos.y-1,z=pos.z-1}
  112. t3 = {x=pos.x,y=pos.y,z=pos.z+1}
  113. elseif p2 == 1 then
  114. t1 = {x=pos.x-1,y=pos.y,z=pos.z}
  115. t2 = {x=pos.x-1,y=pos.y-1,z=pos.z}
  116. t3 = {x=pos.x+1,y=pos.y,z=pos.z}
  117. elseif p2 == 2 then
  118. t1 = {x=pos.x,y=pos.y,z=pos.z+1}
  119. t2 = {x=pos.x,y=pos.y-1,z=pos.z+1}
  120. t3 = {x=pos.x,y=pos.y,z=pos.z-1}
  121. elseif p2 == 3 then
  122. t1 = {x=pos.x+1,y=pos.y,z=pos.z}
  123. t2 = {x=pos.x+1,y=pos.y-1,z=pos.z}
  124. t3 = {x=pos.x-1,y=pos.y,z=pos.z}
  125. end
  126. minetest.set_node(t1,{name="my_garage_door:garage_door_top",param2=p2})
  127. minetest.set_node(t2,{name="my_garage_door:garage_door",param2=p2})
  128. minetest.set_node(pos,{name="air"})
  129. minetest.set_node(t3,{name="air"})
  130. end,
  131. })
  132. minetest.register_node("my_garage_door:garage_door_open2", {
  133. tiles = {
  134. "default_snow.png"
  135. },
  136. drawtype = "nodebox",
  137. paramtype = "light",
  138. paramtype2= "facedir",
  139. drop = "",
  140. diggable = false,
  141. pointable = false,
  142. groups = {cracky=3},
  143. node_box = {
  144. type = "fixed",
  145. fixed = {
  146. {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
  147. {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
  148. {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
  149. {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
  150. {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
  151. }
  152. },
  153. selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
  154. })