plastic.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. plastic = { }
  2. -- deps
  3. --[[
  4. TODO:
  5. extruder to get various pieces of stuff
  6. ]]
  7. minetest.register_craft({
  8. type = "shapeless",
  9. output = 'homedecor:plastic_base 4',
  10. recipe = { "group:leaves",
  11. "group:leaves",
  12. "group:leaves",
  13. "group:leaves",
  14. "group:leaves",
  15. "group:leaves"
  16. }
  17. })
  18. -- plastic block
  19. minetest.register_node( "plastic:plastic_rod", {
  20. description = "Plastic Rod",
  21. tiles = { "plastic_plastic_block.png" },
  22. paramtype = "light",
  23. groups = {cracky=2},
  24. sounds = default.node_sound_stone_defaults(),
  25. drawtype = "nodebox",
  26. node_box = {
  27. type = "fixed",
  28. fixed = {
  29. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  30. },
  31. },
  32. selection_box = {
  33. type = "fixed",
  34. fixed = {
  35. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  36. },
  37. },
  38. })
  39. minetest.register_node( "plastic:plastic_rod_2d_cross", {
  40. description = "Plastic Cross (2D)",
  41. tiles = { "plastic_plastic_block.png" },
  42. paramtype = "light",
  43. groups = {cracky=2},
  44. sounds = default.node_sound_stone_defaults(),
  45. drawtype = "nodebox",
  46. node_box = {
  47. type = "fixed",
  48. fixed = {
  49. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  50. {-0.5, -0.1, -0.1, 0.5, 0.1, 0.1},
  51. },
  52. },
  53. selection_box = {
  54. type = "fixed",
  55. fixed = {
  56. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  57. {-0.5, -0.1, -0.1, 0.5, 0.1, 0.1},
  58. },
  59. },
  60. })
  61. minetest.register_node( "plastic:plastic_rod_3d_cross", {
  62. description = "Plastic Cross (3D)",
  63. tiles = { "plastic_plastic_block.png" },
  64. paramtype = "light",
  65. groups = {cracky=2},
  66. sounds = default.node_sound_stone_defaults(),
  67. drawtype = "nodebox",
  68. node_box = {
  69. type = "fixed",
  70. fixed = {
  71. {-0.1, -0.1, -0.5, 0.1, 0.1, 0.5},
  72. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  73. {-0.5, -0.1, -0.1, 0.5, 0.1, 0.1},
  74. },
  75. },
  76. selection_box = {
  77. type = "fixed",
  78. fixed = {
  79. {-0.1, -0.1, -0.5, 0.1, 0.1, 0.5},
  80. {-0.1, -0.5, -0.1, 0.1, 0.5, 0.1},
  81. {-0.5, -0.1, -0.1, 0.5, 0.1, 0.1},
  82. },
  83. },
  84. })
  85. -- plastic block
  86. minetest.register_node( "plastic:plastic_block", {
  87. description = "Plastic Block",
  88. tiles = { "plastic_plastic_block.png" },
  89. groups = {choppy=2},
  90. sounds = default.node_sound_wood_defaults(),
  91. })
  92. minetest.register_craft( {
  93. output = "plastic:plastic_rod 1",
  94. recipe = {
  95. { "homedecor:plastic_sheeting", "", "" },
  96. { "homedecor:plastic_sheeting", "", "" },
  97. { "homedecor:plastic_sheeting", "", "" }
  98. },
  99. })
  100. minetest.register_craft( {
  101. output = "plastic:plastic_rod_2d_cross 1",
  102. recipe = {
  103. { "", "homedecor:plastic_sheeting", "" },
  104. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
  105. { "", "homedecor:plastic_sheeting", "" }
  106. },
  107. })
  108. minetest.register_craft( {
  109. output = "plastic:plastic_rod_3d_cross 1",
  110. recipe = {
  111. { "", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
  112. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
  113. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "" }
  114. },
  115. })
  116. -- if minetest.get_modpath("moreblocks")
  117. -- table.insert(circular_saw.known_stairs, v);
  118. minetest.register_craft({
  119. type = "shapeless",
  120. output = "plastic:plastic_block 1",
  121. recipe = { "homedecor:plastic_rod",
  122. "homedecor:plastic_rod",
  123. "homedecor:plastic_rod",
  124. "homedecor:plastic_rod",
  125. "homedecor:plastic_rod",
  126. "homedecor:plastic_rod",
  127. "homedecor:plastic_rod",
  128. "homedecor:plastic_rod",
  129. "homedecor:plastic_rod"
  130. }
  131. })
  132. minetest.register_craft( {
  133. type = "shapeless",
  134. output = "homedecor:plastic_sheeting 9",
  135. recipe = { "plastic:plastic_block" }
  136. })
  137. --register nodes in circular saw if aviable
  138. if circular_saw then
  139. for i,v in ipairs({"plastic_block"}) do
  140. table.insert(circular_saw.known_stairs, "plastic:" ..v);
  141. end
  142. end
  143. -- plastic stairs -- hopefully this does what i think it does
  144. register_stair_slab_panel_micro("plastic", "plastic", "plastic:plastic_block",
  145. {cracky=3, not_in_creative_inventory=1},
  146. {"plastic_plastic_block.png"},
  147. "Plastic",
  148. "plastic",
  149. "facedir",
  150. 0)
  151. -- conductor tube recipe
  152. minetest.register_craft( {
  153. output = "pipeworks:conductor_tube_off_000000 3",
  154. recipe = {
  155. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
  156. { "mesecons:mesecon", "mesecons:mesecon", "mesecons:mesecon" },
  157. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
  158. },
  159. })
  160. -- plastic tube recipe
  161. minetest.register_craft( {
  162. output = "pipeworks:tube 3",
  163. recipe = {
  164. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
  165. { "", "", "" },
  166. { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
  167. },
  168. })
  169. -- plastic chest
  170. minetest.register_craft({
  171. output = 'plastic:plastic_chest',
  172. recipe = {
  173. {'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
  174. {'homedecor:plastic_sheeting', '', 'homedecor:plastic_sheeting'},
  175. {'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
  176. }
  177. })
  178. plastic.plastic_chest_formspec =
  179. "size[8,10]"..
  180. "field[10,10;6,1;text;;${text}]"..
  181. "button[100,10;20,1;save;save]"..
  182. "list[current_name;main;0,1;8,4;]"..
  183. "list[current_player;main;0,6;8,4;]"
  184. minetest.register_node("plastic:plastic_chest", {
  185. description = "Plastic Chest",
  186. tiles = {"plastic_plastic_block.png^plastic_plastic_chest_top.png",
  187. "plastic_plastic_block.png^plastic_plastic_chest_top.png",
  188. "plastic_plastic_block.png^plastic_plastic_chest_side.png",
  189. "plastic_plastic_block.png^plastic_plastic_chest_side.png",
  190. "plastic_plastic_block.png^plastic_plastic_chest_side.png",
  191. "plastic_plastic_block.png^plastic_plastic_chest_front.png"},
  192. paramtype2 = "facedir",
  193. groups = {choppy=2,oddly_breakable_by_hand=2},
  194. legacy_facedir_simple = true,
  195. sounds = default.node_sound_wood_defaults(),
  196. on_construct = function(pos)
  197. local meta = minetest.get_meta(pos)
  198. meta:set_string("formspec",plastic.plastic_chest_formspec)
  199. meta:set_string("infotext", "Plastic Chest")
  200. local inv = meta:get_inventory()
  201. inv:set_size("main", 8*4)
  202. end,
  203. can_dig = function(pos,player)
  204. local meta = minetest.get_meta(pos);
  205. local inv = meta:get_inventory()
  206. return inv:is_empty("main")
  207. end,
  208. on_receive_fields = function(pos, formname, fields, sender)
  209. --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
  210. local meta = minetest.get_meta(pos)
  211. fields.text = fields.text or ""
  212. print((sender:get_player_name() or "").." wrote \""..fields.text..
  213. "\" to Plastic Chest at "..minetest.pos_to_string(pos))
  214. meta:set_string("text", fields.text)
  215. meta:set_string("infotext", '"'..fields.text..'"')
  216. end,
  217. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  218. minetest.log("action", player:get_player_name()..
  219. " moves stuff in chest at "..minetest.pos_to_string(pos))
  220. end,
  221. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  222. minetest.log("action", player:get_player_name()..
  223. " moves stuff to chest at "..minetest.pos_to_string(pos))
  224. end,
  225. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  226. minetest.log("action", player:get_player_name()..
  227. " takes stuff from chest at "..minetest.pos_to_string(pos))
  228. end,
  229. })
  230. -- pipeworks plastic chest integration
  231. -- extractor plastic into oil
  232. -- oil shale