concrete.lua 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. minetest.register_node("bitumen:concrete", {
  2. description = "Foundation Concrete",
  3. drawtype = "normal",
  4. tiles = {"default_silver_sand.png^[colorize:black:120"},
  5. groups = {cracky = 1},
  6. })
  7. minetest.register_node("bitumen:concrete_slab", {
  8. description = "Foundation Concrete Slab",
  9. drawtype = "nodebox",
  10. tiles = {"default_silver_sand.png^[colorize:black:120"},
  11. paramtype = "light",
  12. paramtype2 = "facedir",
  13. groups = {cracky = 1},
  14. node_box = {
  15. type = "fixed",
  16. fixed = {
  17. {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
  18. },
  19. },
  20. })
  21. minetest.register_node("bitumen:curing_concrete", {
  22. description = "Foundation Concrete Slab",
  23. drawtype = "nodebox",
  24. tiles = {"default_silver_sand.png^[colorize:black:160"},
  25. paramtype = "light",
  26. groups = {cracky=1},
  27. leveled = 64,
  28. node_box = {
  29. type = "leveled",
  30. fixed = {
  31. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  32. }
  33. },
  34. drop = "",
  35. on_timer = function(pos)
  36. local bpos = {x=pos.x, y=pos.y-1, z=pos.z}
  37. local bnode = minetest.get_node(bpos)
  38. local level = minetest.get_node_level(pos)
  39. if bnode and bnode.name == "bitumen:concrete_slab" then
  40. if level > 42 then
  41. minetest.set_node(bpos, {name="bitumen:concrete"})
  42. minetest.set_node(pos, {name="bitumen:concrete_slab"})
  43. elseif level > 10 then
  44. minetest.set_node(bpos, {name="bitumen:concrete"})
  45. minetest.set_node(pos, {name="air"})
  46. else
  47. minetest.set_node(pos, {name="air"})
  48. end
  49. else
  50. if level > 42 then
  51. minetest.set_node(pos, {name="bitumen:concrete"})
  52. elseif level > 10 then
  53. minetest.set_node(pos, {name="bitumen:concrete_slab"})
  54. else
  55. minetest.set_node(pos, {name="air"})
  56. end
  57. end
  58. end,
  59. })
  60. minetest.register_abm({
  61. nodenames = {"bitumen:wet_concrete", "bitumen:wet_concrete_full", "bitumen:curing_concrete"},
  62. interval = 2,
  63. chance = 5,
  64. catch_up = true,
  65. action = function(pos)
  66. local t = minetest.get_node_timer(pos)
  67. if not t:is_started() then
  68. t:start(15*60) -- concrete takes 30 minutes to cure at best
  69. -- minetest.get_node_timer(pos):start(5) -- fast cure for debugging
  70. end
  71. end
  72. })
  73. bitumen.register_fluid("bitumen", "wet_concrete", {
  74. desc = "Wet Concrete",
  75. groups = {flammable=1, petroleum=1},
  76. colorize = "^[colorize:gray:230",
  77. post_effect_color = {a = 10, r = 30, g = 20, b = 10},
  78. no_default_soak = true,
  79. evap_chance = 0,
  80. def = {
  81. on_timer = function(pos)
  82. local level = minetest.get_node_level(pos)
  83. minetest.set_node(pos, {name="bitumen:curing_concrete"})
  84. minetest.set_node_level(pos, level)
  85. end
  86. },
  87. })
  88. local cement_mixer_formspec =
  89. "size[10,9;]" ..
  90. default.gui_bg ..
  91. default.gui_bg_img ..
  92. default.gui_slots ..
  93. "list[context;main;0,0.3;5,4;]" ..
  94. "list[current_player;main;0,4.85;8,1;]" ..
  95. "list[current_player;main;0,6.08;8,3;8]" ..
  96. "listring[context;main]" ..
  97. "listring[current_player;main]" ..
  98. default.get_hotbar_bg(0, 4.85)
  99. minetest.register_node("bitumen:cement_mixer", {
  100. paramtype = "light",
  101. drawtype = "mesh",
  102. mesh = "cement_mixer.obj",
  103. description = "Cement Mixer",
  104. inventory_image = "bitumen_cement_mixer_invimg.png",
  105. tiles = {
  106. "default_snow.png",
  107. },
  108. selection_box = {
  109. type = "fixed",
  110. fixed = {
  111. { -.5, -.5, -.5, .5, 1.5, .5 },
  112. { 1.5, 1.5, 1.5, -1.5, 4.5, -1.5 },
  113. },
  114. },
  115. collision_box = {
  116. type = "fixed",
  117. fixed = {
  118. { -.5, -.5, -.5, .5, 1.5, .5 },
  119. { -1.5, -1.5, -1.5, -1.4, 3, -1.4 },
  120. { 1.5, -1.5, -1.5, 1.4, 3, -1.4 },
  121. { -1.5, -1.5, 1.5, -1.4, 3, 1.4 },
  122. { 1.5, -1.5, 1.5, 1.4, 3, 1.4 },
  123. { 1.5, 1.5, 1.5, -1.5, 4.5, -1.5 },
  124. }
  125. },
  126. paramtype2 = "facedir",
  127. groups = {cracky=1, petroleum_fixture=1},
  128. sounds = default.node_sound_wood_defaults(),
  129. on_construct = function(pos)
  130. local meta = minetest.get_meta(pos)
  131. local inv = meta:get_inventory()
  132. inv:set_size("main", 20)
  133. meta:set_string("formspec", cement_mixer_formspec);
  134. end,
  135. on_timer = function(pos, elapsed)
  136. local meta = minetest.get_meta(pos)
  137. local cache = meta:get_int("cache") or 0
  138. if cache < 32 then
  139. local inv = meta:get_inventory();
  140. if not inv:contains_item("main", "bitumen:lime 1") then
  141. print("not enough lime")
  142. return false
  143. end
  144. if not inv:contains_item("main", "default:gravel 3") then
  145. print("not enough gravel")
  146. return false
  147. end
  148. if not inv:contains_item("main", "bucket:bucket_water 2") then
  149. print("not enough water")
  150. return false
  151. end
  152. if not (
  153. inv:contains_item("main", "default:sand 3")
  154. ) then
  155. print("not enough sand")
  156. return false
  157. end
  158. inv:remove_item("main", "default:sand 1")
  159. inv:remove_item("main", "default:sand 1")
  160. inv:remove_item("main", "default:sand 1")
  161. inv:remove_item("main", "bitumen:lime 1")
  162. inv:remove_item("main", "default:gravel 1")
  163. inv:remove_item("main", "default:gravel 1")
  164. inv:remove_item("main", "default:gravel 1")
  165. cache = cache + (9 * 64)
  166. end
  167. local pushed = bitumen.pipes.push_fluid({x=pos.x, y=pos.y-1, z=pos.z}, "bitumen:wet_concrete", 32, 1)
  168. meta:set_int("cache", cache - pushed)
  169. return true
  170. end,
  171. can_dig = function(pos, player)
  172. local meta = minetest.get_meta(pos);
  173. local inv = meta:get_inventory();
  174. return inv:is_empty("main")
  175. end,
  176. -- spit out some concrete
  177. on_punch = function(pos)
  178. local timer = minetest.get_node_timer(pos)
  179. if timer:is_started() then
  180. timer:stop()
  181. else
  182. timer:start(3.0)
  183. end
  184. end,
  185. })
  186. bitumen.register_blueprint({
  187. name="bitumen:cement_mixer",
  188. no_constructor_craft = true,
  189. })
  190. minetest.register_abm({
  191. nodenames = {"bitumen:concrete_mixer"},
  192. interval = 2,
  193. chance = 1,
  194. action = function(pos)
  195. minetest.get_node_timer(pos):start(30*60) -- concrete takes half an hour to cure at best
  196. end
  197. })
  198. minetest.register_node("bitumen:chalk", {
  199. description = "Chalk",
  200. drawtype = "normal",
  201. tiles = {"default_clay.png^[colorize:white:80"},
  202. groups = {crumbly = 3, cracky = 3},
  203. })
  204. minetest.register_node("bitumen:lime", {
  205. description = "Lime",
  206. drawtype = "normal",
  207. tiles = {"default_clay.png^[colorize:white:160"},
  208. groups = {crumbly = 3},
  209. })
  210. -- 1 part cement
  211. -- 2 parts water
  212. -- 3 parts sand
  213. -- 3 parts gravel