123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- -- need:
- -- bottler?
- local function mul(t, x)
- local o = {}
-
- for n,i in ipairs(t) do
- o[n] = i * x
- end
-
- o[2] = o[2] / x
- o[5] = o[5] / x
-
- return o
- end
-
- --
- -- usage: alternate distillation columns and dist. col. outlets
- -- put boiler on the bottom
- -- pipe various distillates out
- --
- --
- minetest.register_node("bitumen:distillation_column", {
- paramtype = "light",
- description = "Distillation Column Segment",
- tiles = {"bitumen_cracking_column.png", "bitumen_cracking_column.png", "bitumen_cracking_column.png",
- "bitumen_cracking_column.png", "bitumen_cracking_column.png", "bitumen_cracking_column.png"},
- node_box = {
- type = "fixed",
- fixed = {
- --11.25
- mul({-0.49, -0.5, -0.10, 0.49, 0.5, 0.10}, 1.5),
- mul({-0.10, -0.5, -0.49, 0.10, 0.5, 0.49}, 1.5),
- --22.5
- mul({-0.46, -0.5, -0.19, 0.46, 0.5, 0.19}, 1.5),
- mul({-0.19, -0.5, -0.46, 0.19, 0.5, 0.46}, 1.5),
- -- 33.75
- mul({-0.416, -0.5, -0.28, 0.416, 0.5, 0.28}, 1.5),
- mul({-0.28, -0.5, -0.416, 0.28, 0.5, 0.416}, 1.5),
- --45
- mul({-0.35, -0.5, -0.35, 0.35, 0.5, 0.35}, 1.5),
- },
- },
- selection_box = {
- type = "fixed",
- fixed = {
- mul({-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, 1.5),
- },
- },
- drawtype = "nodebox",
- groups = {cracky=3,oddly_breakable_by_hand=3 },
- legacy_facedir_simple = true,
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
-
- end,
- })
- minetest.register_node("bitumen:distillation_column_outlet", {
- paramtype = "light",
- description = "Distillation Column Outlet",
- tiles = {"bitumen_cracking_column.png", "bitumen_cracking_column_outlet.png", "bitumen_cracking_column_outlet.png",
- "bitumen_cracking_column_outlet.png", "bitumen_cracking_column_outlet.png", "bitumen_cracking_column.png"},
- node_box = {
- type = "fixed",
- fixed = {
- --11.25
- mul({-0.49, -0.5, -0.10, 0.49, 0.5, 0.10}, 1.5),
- mul({-0.10, -0.5, -0.49, 0.10, 0.5, 0.49}, 1.5),
- --22.5
- mul({-0.46, -0.5, -0.19, 0.46, 0.5, 0.19}, 1.5),
- mul({-0.19, -0.5, -0.46, 0.19, 0.5, 0.46}, 1.5),
- -- 33.75
- mul({-0.416, -0.5, -0.28, 0.416, 0.5, 0.28}, 1.5),
- mul({-0.28, -0.5, -0.416, 0.28, 0.5, 0.416}, 1.5),
- --45
- mul({-0.35, -0.5, -0.35, 0.35, 0.5, 0.35}, 1.5),
- },
- },
- selection_box = {
- type = "fixed",
- fixed = {
- mul({-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, 1.0)
- },
- },
- drawtype = "nodebox",
- groups = {cracky=3,oddly_breakable_by_hand=3, petroleum_fixture=1},
- legacy_facedir_simple = true,
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
- -- connect to the pipe network
- bitumen.pipes.on_construct(pos)
- end,
- })
- bitumen.distillation_stack = {
- "tar",
- "heavy_oil",
- "light_oil",
- "diesel",
- "kerosene",
- "gasoline",
- "mineral_spirits",
- -- "lpg",
- }
-
- local function check_stack(opos)
- local ret = { }
- local oh = opos.y
- local pos = {x=opos.x, y=opos.y+1, z=opos.z}
- local height = 0
- local n
-
- while height < 7 do
- local n = minetest.get_node(pos)
- if n.name == "bitumen:distillation_column" then
- -- noop
- --print("col")
- elseif n.name == "bitumen:distillation_column_outlet" then
- height = height+1
- --local t = bitumen.distillation_stack[height]
-
- ret[height] = {x=pos.x, y=pos.y, z=pos.z}
-
- --print(t.." at ".. (pos.y).. " - " .. height)
- else
- --print("n "..n.name)
- -- end of the stack
- break
- end
-
- pos.y = pos.y+1
- end
- --print("returning")
- return ret
- end
- local function dcb_node_timer(pos, elapsed)
-
-
-
- end
- local function swap_node(pos, name)
- local node = minetest.get_node(pos)
- if node.name == name then
- return
- end
- node.name = name
- minetest.swap_node(pos, node)
- end
- bitumen.register_burner({"bitumen:distillation_column_boiler_on"}, {
- start_cook = function()
- --print("starting")
-
- return 2
- end,
- finish_cook = function(pos)
- --print("y1 ".. pos.y)
- local input = bitumen.pipes.take_fluid(pos, 64)
- print(pos.x .. " crude taken: ".. input)
- if input <= 0 then
- return
- end
- --print("y2 ".. pos.y)
- local stack = check_stack(pos)
- --print("y3 ".. pos.y)
- for i,p in ipairs(stack) do
- local fluid = bitumen.distillation_stack[i]
- local yield = bitumen.distillation_yield[fluid] * (input / 100) -- convert to levels
- --print("pushing "..yield.. " " ..fluid.." at "..p.y)
- bitumen.pipes.push_fluid(p, "bitumen:"..fluid, yield, 20)
- end
- end,
- get_formspec_on = get_melter_active_formspec,
- }, 5.0)
- minetest.register_node("bitumen:distillation_column_boiler", {
- description = "Distillation Column Boiler",
- tiles = {
- "default_bronze_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_furnace_front.png",
- },
- paramtype2 = "facedir",
- groups = {cracky=2, petroleum_fixture=1},
- is_ground_content = false,
- sounds = default.node_sound_stone_defaults(),
- --can_dig = can_dig,
-
- --on_timer = burner_on_timer,
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", bitumen.get_melter_active_formspec())
- local inv = meta:get_inventory()
- inv:set_size('fuel', 4)
-
- bitumen.pipes.on_construct(pos)
-
- minetest.get_node_timer(pos):start(1.0)
-
- end,
- -- on_metadata_inventory_move = function(pos)
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- -- on_metadata_inventory_put = function(pos)
- -- -- start timer function, it will sort out whether furnace can burn or not.
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- --
-
- on_punch = function(pos)
- swap_node(pos, "bitumen:distillation_column_boiler_on")
- minetest.get_node_timer(pos):start(1.0)
- end,
-
-
- -- on_blast = function(pos)
- -- local drops = {}
- -- default.get_inventory_drops(pos, "src", drops)
- -- default.get_inventory_drops(pos, "fuel", drops)
- -- default.get_inventory_drops(pos, "dst", drops)
- -- drops[#drops+1] = "machines:machine"
- -- minetest.remove_node(pos)
- -- return drops
- -- end,
- allow_metadata_inventory_put = allow_metadata_inventory_put,
- allow_metadata_inventory_move = allow_metadata_inventory_move,
- allow_metadata_inventory_take = allow_metadata_inventory_take,
- })
-
- minetest.register_node("bitumen:distillation_column_boiler_on", {
- description = "Distillation Column Boiler",
- tiles = {
- "default_tin_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_tin_block.png",
- "default_tin_block.png",
- {
- image = "default_furnace_front_active.png",
- backface_culling = false,
- animation = {
- type = "vertical_frames",
- aspect_w = 16,
- aspect_h = 16,
- length = 1.5
- },
- }
- },
- paramtype2 = "facedir",
- groups = {cracky=2, petroleum_fixture=1, not_in_creative_inventory=1},
- is_ground_content = false,
- sounds = default.node_sound_stone_defaults(),
- --can_dig = can_dig,
-
- on_timer = bitumen.burner_on_timer,
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", bitumen.get_melter_active_formspec())
- local inv = meta:get_inventory()
- inv:set_size('fuel', 4)
-
- bitumen.pipes.on_construct(pos)
-
- minetest.get_node_timer(pos):start(1.0)
-
- end,
- -- on_metadata_inventory_move = function(pos)
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- -- on_metadata_inventory_put = function(pos)
- -- -- start timer function, it will sort out whether furnace can burn or not.
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- --
-
- on_punch = function(pos)
- swap_node(pos, "bitumen:distillation_column_boiler")
- end,
- allow_metadata_inventory_put = allow_metadata_inventory_put,
- allow_metadata_inventory_move = allow_metadata_inventory_move,
- allow_metadata_inventory_take = allow_metadata_inventory_take,
- })
- -- must add up to 100
- bitumen.distillation_yield = {
- tar = 20,
- heavy_oil = 20,
- light_oil = 10,
- diesel = 20,
- kerosene = 15,
- gasoline = 10,
- mineral_spirits = 5,
- }
- -- TODO: more
- bitumen.cracking_yield = {
- ["bitumen:tar"] = {
- {"tar", 40},
- {"heavy_oil", 30},
- {"light_oil", 20},
- {"diesel", 10},
- },
-
- ["bitumen:heavy_oil"] = {
- {"heavy_oil", 30},
- {"light_oil", 30},
- {"diesel", 30},
- {"kerosene", 10},
- },
-
- ["bitumen:light_oil"] = {
- {"light_oil", 30},
- {"diesel", 30},
- {"kerosene", 20},
- {"gasoline", 20},
- },
-
- ["bitumen:diesel"] = {
- {"diesel", 20},
- {"kerosene", 30},
- {"gasoline", 25},
- {"mineral_spirits", 25},
- },
- ["bitumen:kerosene"] = {
- {"kerosene", 10},
- {"gasoline", 30},
- {"mineral_spirits", 30},
- --lpg = 30,
- },
-
- ["bitumen:gasoline"] = {
- {"gasoline", 5},
- {"mineral_spirits", 40},
- -- lpg = 40,
- -- ethane = 15,
- },
-
- ["bitumen:mineral_spirits"] = {
- {"mineral_spirits", 10},
- -- lpg = 60,
- -- ethane = 30,
- },
-
- }
- -- cracking columns
- bitumen.register_burner({"bitumen:cracking_boiler_on"}, {
- start_cook = function()
- return 2
- end,
- finish_cook = function(pos)
- local input, influid = bitumen.pipes.take_fluid(pos, 64)
- if input <= 0 then
- return
- end
-
- local ytable = bitumen.cracking_yield[influid]
- if not ytable then
- return
- end
- local stack = check_stack(pos)
- for i,p in ipairs(stack) do
- local def = ytable[i]
- if not def then
- break
- end
-
- local yield = def[2] * (input / 100) -- convert to levels
- bitumen.pipes.push_fluid(p, "bitumen:"..def[1], yield, 20)
- end
- end,
- get_formspec_on = get_melter_active_formspec,
- }, 5.0)
- minetest.register_node("bitumen:cracking_boiler", {
- description = "Cracking Column Boiler",
- tiles = {
- "default_bronze_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_furnace_front.png",
- },
- paramtype2 = "facedir",
- groups = {cracky=2, petroleum_fixture=1},
- is_ground_content = false,
- sounds = default.node_sound_stone_defaults(),
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", bitumen.get_melter_active_formspec())
- local inv = meta:get_inventory()
- inv:set_size('fuel', 4)
-
- bitumen.pipes.on_construct(pos)
-
- minetest.get_node_timer(pos):start(1.0)
-
- end,
-
- on_punch = function(pos)
- swap_node(pos, "bitumen:cracking_boiler_on")
- minetest.get_node_timer(pos):start(1.0)
- end,
- allow_metadata_inventory_put = allow_metadata_inventory_put,
- allow_metadata_inventory_move = allow_metadata_inventory_move,
- allow_metadata_inventory_take = allow_metadata_inventory_take,
- })
- minetest.register_node("bitumen:cracking_boiler_on", {
- description = "Cracking Column Boiler",
- tiles = {
- "default_tin_block.png", "default_bronze_block.png",
- "default_bronze_block.png", "default_tin_block.png",
- "default_tin_block.png",
- {
- image = "default_furnace_front_active.png",
- backface_culling = false,
- animation = {
- type = "vertical_frames",
- aspect_w = 16,
- aspect_h = 16,
- length = 1.5
- },
- }
- },
- paramtype2 = "facedir",
- groups = {cracky=2, petroleum_fixture=1, not_in_creative_inventory=1},
- is_ground_content = false,
- sounds = default.node_sound_stone_defaults(),
- --can_dig = can_dig,
-
- on_timer = bitumen.burner_on_timer,
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", bitumen.get_melter_active_formspec())
- local inv = meta:get_inventory()
- inv:set_size('fuel', 4)
-
- bitumen.pipes.on_construct(pos)
-
- minetest.get_node_timer(pos):start(1.0)
-
- end,
- -- on_metadata_inventory_move = function(pos)
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- -- on_metadata_inventory_put = function(pos)
- -- -- start timer function, it will sort out whether furnace can burn or not.
- -- minetest.get_node_timer(pos):start(1.0)
- -- end,
- --
-
- on_punch = function(pos)
- swap_node(pos, "bitumen:cracking_boiler")
- end,
- allow_metadata_inventory_put = allow_metadata_inventory_put,
- allow_metadata_inventory_move = allow_metadata_inventory_move,
- allow_metadata_inventory_take = allow_metadata_inventory_take,
- })
|