oilshale.lua 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. --[[ NEED:
  2. textures:
  3. oil shale
  4. crushed oil shale
  5. node defs:
  6. (tweak) oil shale
  7. craftitem:
  8. crushed oil shale
  9. ore reg:
  10. (tweak) oil shale
  11. grinder recipe:
  12. oil shale -> crushed oil shale
  13. extractor recipe:
  14. crushed oil shale -> bitumen
  15. ]]
  16. -- need to get the info for stone-type things
  17. minetest.register_node( "bitumen:tar_sand", {
  18. description = "Tar Sand",
  19. tiles = { "default_sand.png^[colorize:black:180" },
  20. is_ground_content = true,
  21. groups = {crumbly=2, bitumen_mineral = 1, falling_node=1},
  22. sounds = default.node_sound_sand_defaults(),
  23. })
  24. minetest.register_node( "bitumen:oil_shale", {
  25. description = "Oil Shale",
  26. tiles = { "default_stone.png^[colorize:black:180" },
  27. is_ground_content = true,
  28. groups = {cracky=2, bitumen_mineral = 1},
  29. sounds = default.node_sound_stone_defaults(),
  30. })
  31. local function swap_node(pos, name)
  32. local node = minetest.get_node(pos)
  33. if node.name == name then
  34. return
  35. end
  36. node.name = name
  37. minetest.swap_node(pos, node)
  38. end
  39. --[[
  40. local function grab_fuel(inv)
  41. local list = inv:get_list("fuel")
  42. for i,st in ipairs(list) do
  43. print(st:get_name())
  44. local fuel, remains
  45. fuel, remains = minetest.get_craft_result({
  46. method = "fuel",
  47. width = 1,
  48. items = {
  49. ItemStack(st:get_name())
  50. },
  51. })
  52. if fuel.time > 0 then
  53. -- Take fuel from fuel list
  54. st:take_item()
  55. inv:set_stack("fuel", i, st)
  56. return fuel.time
  57. end
  58. end
  59. return 0 -- no fuel found
  60. end
  61. ]]
  62. bitumen.register_burner({"bitumen:mineral_oil_furnace_on"}, {
  63. start_cook = function(pos)
  64. local up = {x=pos.x, y=pos.y + 1, z=pos.z}
  65. local meta = minetest.get_meta(up)
  66. local inv = meta:get_inventory()
  67. local item = inv:remove_item("main", "bitumen:tar_sand 1")
  68. if item == nil or item:get_count() <= 0 then
  69. item = inv:remove_item("main", "bitumen:oil_shale 1")
  70. if item == nil or item:get_count() <= 0 then
  71. print("no minerals")
  72. return 0 -- no minerals to melt
  73. end
  74. return 6 -- oil shale takes longer
  75. end
  76. return 4
  77. end,
  78. finish_cook = function(pos)
  79. local node = minetest.get_node(pos)
  80. local back_dir = minetest.facedir_to_dir(node.param2)
  81. local backpos = vector.add(pos, back_dir)
  82. local backnet = bitumen.pipes.get_net(backpos)
  83. if backnet == nil then
  84. print("mineral furnace no backnet at "..minetest.pos_to_string(backpos))
  85. return
  86. end
  87. local pushed = bitumen.pipes.push_fluid(backpos, "bitumen:crude_oil", 32, 2)
  88. end,
  89. get_formspec_on = get_melter_active_formspec,
  90. turn_off = function(pos)
  91. swap_node(pos, "bitumen:mineral_oil_furnace")
  92. end,
  93. })
  94. minetest.register_node("bitumen:mineral_oil_furnace", {
  95. description = "Mineral Deposit Furnace",
  96. tiles = {
  97. "default_bronze_block.png", "default_bronze_block.png",
  98. "default_bronze_block.png", "default_bronze_block.png",
  99. "default_bronze_block.png", "default_furnace_front.png",
  100. },
  101. paramtype2 = "facedir",
  102. groups = {cracky=2, petroleum_fixture=1},
  103. is_ground_content = false,
  104. on_place = minetest.rotate_node,
  105. sounds = default.node_sound_stone_defaults(),
  106. --can_dig = can_dig,
  107. on_construct = function(pos)
  108. local meta = minetest.get_meta(pos)
  109. meta:set_string("formspec", bitumen.get_melter_active_formspec())
  110. local inv = meta:get_inventory()
  111. inv:set_size('fuel', 4)
  112. minetest.get_node_timer(pos):start(1.0)
  113. end,
  114. on_punch = function(pos)
  115. swap_node(pos, "bitumen:mineral_oil_furnace_on")
  116. minetest.get_node_timer(pos):start(1.0)
  117. end,
  118. })
  119. minetest.register_node("bitumen:mineral_oil_furnace_on", {
  120. description = "Mineral Deposit Furnace (Active)",
  121. tiles = {
  122. "default_bronze_block.png", "default_bronze_block.png",
  123. "default_bronze_block.png", "default_bronze_block.png",
  124. "default_bronze_block.png", {
  125. image = "default_furnace_front_active.png",
  126. backface_culling = false,
  127. animation = {
  128. type = "vertical_frames",
  129. aspect_w = 16,
  130. aspect_h = 16,
  131. length = 1.5
  132. },
  133. }
  134. },
  135. paramtype2 = "facedir",
  136. groups = {cracky=2, petroleum_fixture=1},
  137. is_ground_content = false,
  138. on_place = minetest.rotate_node,
  139. sounds = default.node_sound_stone_defaults(),
  140. --can_dig = can_dig,
  141. on_timer = bitumen.burner_on_timer,
  142. on_construct = function(pos)
  143. local meta = minetest.get_meta(pos)
  144. meta:set_string("formspec", bitumen.get_melter_active_formspec())
  145. local inv = meta:get_inventory()
  146. inv:set_size('fuel', 4)
  147. minetest.get_node_timer(pos):start(1.0)
  148. end,
  149. on_punch = function(pos)
  150. swap_node(pos, "bitumen:mineral_oil_furnace")
  151. minetest.get_node_timer(pos):start(1.0)
  152. end,
  153. })
  154. bitumen.register_blueprint({name="bitumen:mineral_oil_furnace"})
  155. --[[
  156. bitumen.register_burner({"bitumen:engine_on"}, {
  157. start_cook = function()
  158. print("starting-")
  159. return 8
  160. end,
  161. finish_cook = function()
  162. print("ending-")
  163. end,
  164. get_formspec_on = get_melter_active_formspec,
  165. })
  166. minetest.register_node("bitumen:engine", {
  167. description = "Engine",
  168. tiles = {
  169. "default_bronze_block.png", "default_bronze_block.png",
  170. "default_bronze_block.png", "default_bronze_block.png",
  171. "default_bronze_block.png", "default_furnace_front.png",
  172. },
  173. paramtype2 = "facedir",
  174. groups = {cracky=2, petroleum_fixture=1},
  175. is_ground_content = false,
  176. sounds = default.node_sound_stone_defaults(),
  177. --can_dig = can_dig,
  178. --on_timer = burner_on_timer,
  179. on_construct = function(pos)
  180. local meta = minetest.get_meta(pos)
  181. meta:set_string("formspec", get_melter_active_formspec())
  182. local inv = meta:get_inventory()
  183. inv:set_size('fuel', 4)
  184. minetest.get_node_timer(pos):start(1.0)
  185. end,
  186. -- on_metadata_inventory_move = function(pos)
  187. -- minetest.get_node_timer(pos):start(1.0)
  188. -- end,
  189. -- on_metadata_inventory_put = function(pos)
  190. -- -- start timer function, it will sort out whether furnace can burn or not.
  191. -- minetest.get_node_timer(pos):start(1.0)
  192. -- end,
  193. --
  194. on_punch = function(pos)
  195. swap_node(pos, "bitumen:engine_on")
  196. minetest.get_node_timer(pos):start(1.0)
  197. end,
  198. -- on_blast = function(pos)
  199. -- local drops = {}
  200. -- default.get_inventory_drops(pos, "src", drops)
  201. -- default.get_inventory_drops(pos, "fuel", drops)
  202. -- default.get_inventory_drops(pos, "dst", drops)
  203. -- drops[#drops+1] = "machines:machine"
  204. -- minetest.remove_node(pos)
  205. -- return drops
  206. -- end,
  207. allow_metadata_inventory_put = allow_metadata_inventory_put,
  208. allow_metadata_inventory_move = allow_metadata_inventory_move,
  209. allow_metadata_inventory_take = allow_metadata_inventory_take,
  210. })
  211. minetest.register_node("bitumen:engine_on", {
  212. description = "Engine",
  213. tiles = {
  214. "default_tin_block.png", "default_bronze_block.png",
  215. "default_bronze_block.png", "default_tin_block.png",
  216. "default_tin_block.png",
  217. {
  218. image = "default_furnace_front_active.png",
  219. backface_culling = false,
  220. animation = {
  221. type = "vertical_frames",
  222. aspect_w = 16,
  223. aspect_h = 16,
  224. length = 1.5
  225. },
  226. }
  227. },
  228. paramtype2 = "facedir",
  229. groups = {cracky=2, petroleum_fixture=1, not_in_creative_inventory=1},
  230. is_ground_content = false,
  231. sounds = default.node_sound_stone_defaults(),
  232. --can_dig = can_dig,
  233. on_timer = bitumen.burner_on_timer,
  234. on_construct = function(pos)
  235. local meta = minetest.get_meta(pos)
  236. meta:set_string("formspec", get_melter_active_formspec())
  237. local inv = meta:get_inventory()
  238. inv:set_size('fuel', 4)
  239. minetest.get_node_timer(pos):start(1.0)
  240. end,
  241. -- on_metadata_inventory_move = function(pos)
  242. -- minetest.get_node_timer(pos):start(1.0)
  243. -- end,
  244. -- on_metadata_inventory_put = function(pos)
  245. -- -- start timer function, it will sort out whether furnace can burn or not.
  246. -- minetest.get_node_timer(pos):start(1.0)
  247. -- end,
  248. --
  249. on_punch = function(pos)
  250. swap_node(pos, "bitumen:engine")
  251. end,
  252. allow_metadata_inventory_put = allow_metadata_inventory_put,
  253. allow_metadata_inventory_move = allow_metadata_inventory_move,
  254. allow_metadata_inventory_take = allow_metadata_inventory_take,
  255. })
  256. ]]
  257. --[[
  258. minetest.register_ore({
  259. ore_type = "stratum",
  260. ore = "default:meselamp",
  261. wherein = {"default:stone"},
  262. clust_scarcity = 1,
  263. y_min = -8,
  264. y_max = 72,
  265. noise_params = {
  266. offset = 32,
  267. scale = 16,
  268. spread = {x = 256, y = 256, z = 256},
  269. seed = 90122,
  270. octaves = 3,
  271. persist = 0.5
  272. },
  273. np_stratum_thickness = {
  274. offset = 8,
  275. scale = 4,
  276. spread = {x = 128, y = 128, z = 128},
  277. seed = -316,
  278. octaves = 1,
  279. persist = 0.0
  280. },
  281. })
  282. ]]