framed.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. local doorcolors = {"white","red","black"}
  2. for i = 1,#doorcolors do
  3. local col = doorcolors[i]
  4. minetest.register_node("my_future_doors:door1a_"..col, {
  5. description = "Door 1a",
  6. tiles = {
  7. "myndoors_door1_"..col..".png",
  8. "myndoors_door1_"..col..".png",
  9. "myndoors_door1_"..col..".png",
  10. "myndoors_door1_"..col..".png",
  11. "myndoors_door1_"..col.."b.png",
  12. "myndoors_door1_"..col.."b.png"
  13. },
  14. drawtype = "nodebox",
  15. paramtype = "light",
  16. paramtype2 = "facedir",
  17. groups = {cracky = 3},
  18. node_box = {
  19. type = "fixed",
  20. fixed = {
  21. {-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625},
  22. {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
  23. {0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
  24. {0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
  25. {0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
  26. {-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
  27. {-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
  28. }
  29. },
  30. selection_box = {
  31. type = "fixed",
  32. fixed = {
  33. {-0.4375, -0.5, -0.1875, 0.4375, 1.5, -0.0625}, --door
  34. {0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right
  35. {-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left
  36. {-0.625, 1.4375, -0.5625, 0.625, 1.625, 0.5625}, --top
  37. }
  38. },
  39. on_place = function(itemstack, placer, pointed_thing)
  40. local pos1 = pointed_thing.above
  41. local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z}
  42. pos2.y = pos2.y+1
  43. if
  44. not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
  45. not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or
  46. not placer or
  47. not placer:is_player() then
  48. return
  49. end
  50. return minetest.item_place(itemstack, placer, pointed_thing)
  51. end,
  52. after_place_node = function(pos, placer, itemstack, pointed_thing)
  53. local node = minetest.get_node(pos)
  54. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1b_"..col,param2=node.param2})
  55. end,
  56. after_destruct = function(pos, oldnode)
  57. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
  58. end,
  59. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  60. local timer = minetest.get_node_timer(pos)
  61. if node.name == "my_future_doors:door1a_"..col then
  62. minetest.set_node(pos,{name="my_future_doors:door1c_"..col,param2=node.param2})
  63. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1d_"..col,param2=node.param2})
  64. timer:start(3)
  65. end
  66. end,
  67. })
  68. minetest.register_node("my_future_doors:door1b_"..col, {
  69. tiles = {
  70. "myndoors_door1_"..col..".png",
  71. "myndoors_door1_"..col..".png",
  72. "myndoors_door1_"..col..".png",
  73. "myndoors_door1_"..col..".png",
  74. "myndoors_door1_"..col.."b.png",
  75. "myndoors_door1_"..col.."b.png"
  76. },
  77. drawtype = "nodebox",
  78. paramtype = "light",
  79. paramtype2 = "facedir",
  80. groups = {cracky = 1},
  81. node_box = {
  82. type = "fixed",
  83. fixed = {
  84. {-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625},
  85. {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
  86. {0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
  87. {0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
  88. {0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
  89. {-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
  90. {-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
  91. {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
  92. {-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5},
  93. {-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625},
  94. }
  95. },
  96. selection_box = {
  97. type = "fixed",
  98. fixed = {
  99. {-0.5, -0.5, -0.5, -0.5, -0.5, -0.5},
  100. }
  101. },
  102. })minetest.register_node("my_future_doors:door1c_"..col, {
  103. tiles = {
  104. "myndoors_door1_"..col..".png",
  105. "myndoors_door1_"..col..".png",
  106. "myndoors_door1_"..col..".png",
  107. "myndoors_door1_"..col..".png",
  108. "myndoors_door1_"..col.."b.png",
  109. "myndoors_door1_"..col.."b.png"
  110. },
  111. drawtype = "nodebox",
  112. paramtype = "light",
  113. paramtype2 = "facedir",
  114. groups = {cracky = 1},
  115. node_box = {
  116. type = "fixed",
  117. fixed = {
  118. {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
  119. {0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
  120. {0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
  121. {0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
  122. {-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
  123. {-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
  124. }
  125. },
  126. selection_box = {
  127. type = "fixed",
  128. fixed = {
  129. {0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right
  130. {-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left
  131. {-0.625, 1.4375, -0.5625, 0.625, 1.625, 0.5625}, --top
  132. }
  133. },
  134. after_place_node = function(pos, placer, itemstack, pointed_thing)
  135. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1d_"..col,param2=nodeu.param2})
  136. end,
  137. after_destruct = function(pos, oldnode)
  138. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
  139. end,
  140. on_timer = function(pos, elapsed)
  141. local node = minetest.get_node(pos)
  142. minetest.set_node(pos,{name="my_future_doors:door1a_"..col,param2=node.param2})
  143. minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1b_"..col,param2=node.param2})
  144. end,
  145. })
  146. minetest.register_node("my_future_doors:door1d_"..col, {
  147. tiles = {
  148. "myndoors_door1_"..col..".png",
  149. "myndoors_door1_"..col..".png",
  150. "myndoors_door1_"..col..".png",
  151. "myndoors_door1_"..col..".png",
  152. "myndoors_door1_"..col.."b.png",
  153. "myndoors_door1_"..col.."b.png"
  154. },
  155. drawtype = "nodebox",
  156. paramtype = "light",
  157. paramtype2 = "facedir",
  158. groups = {cracky = 1},
  159. node_box = {
  160. type = "fixed",
  161. fixed = {
  162. {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
  163. {0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
  164. {0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
  165. {0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
  166. {-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
  167. {-0.625, -0.5, 0.5, -0.4375, 0.4375, 0.5625},
  168. {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
  169. {-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5},
  170. {-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625},
  171. }
  172. },
  173. selection_box = {
  174. type = "fixed",
  175. fixed = {
  176. {-0.5, -0.5, -0.5, -0.5, -0.5, -0.5},
  177. }
  178. },
  179. })
  180. minetest.register_craft({
  181. output = "my_future_doors:door1a_"..col.." 1",
  182. recipe = {
  183. {"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col},
  184. {"wool:"..col, "my_door_wood:wood_"..col, "wool:"..col},
  185. {"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col}
  186. }
  187. })
  188. end