mirror of
https://github.com/sirrobzeroone/elepower.git
synced 2024-08-20 21:04:06 +02:00
Convert biomass and sludge to biofuel as well
This commit is contained in:
parent
89bc723fca
commit
d36b49edb3
@ -1,9 +1,10 @@
|
||||
|
||||
local function get_formspec(timer, output_buffer)
|
||||
local function get_formspec(timer, biomass_buffer, output_buffer)
|
||||
return "size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
ele.formspec.fluid_bar(0, 0.75, biomass_buffer)..
|
||||
ele.formspec.fluid_bar(7, 0.75, output_buffer)..
|
||||
"list[context;src;1,0.5;3,3;]"..
|
||||
"image[5,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||
@ -54,6 +55,7 @@ local function on_timer(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local in_buffer = fluid_lib.get_buffer_data(pos, "input")
|
||||
local out_buffer = fluid_lib.get_buffer_data(pos, "output")
|
||||
|
||||
local time = meta:get_int("src_time")
|
||||
@ -62,7 +64,7 @@ local function on_timer(pos, elapsed)
|
||||
while true do
|
||||
local amount,list_new = get_biomass(inv:get_list("src"))
|
||||
|
||||
if amount == 0 or out_buffer.amount == out_buffer.capacity then
|
||||
if (amount == 0 and in_buffer.amount == 0) or out_buffer.amount == out_buffer.capacity then
|
||||
break
|
||||
end
|
||||
|
||||
@ -81,7 +83,29 @@ local function on_timer(pos, elapsed)
|
||||
break
|
||||
end
|
||||
|
||||
local amount_fluid = amount * 100
|
||||
local amount_fluid = 0
|
||||
if amount > 0 then
|
||||
amount_fluid = amount_fluid + (amount * 100)
|
||||
end
|
||||
|
||||
if in_buffer.amount > 0 then
|
||||
local rm = math.min(in_buffer.amount, 1000)
|
||||
|
||||
-- Remove 20% from sludge
|
||||
if in_buffer.fluid == "elepower_farming:sludge_source" then
|
||||
local pcr = math.floor(rm * 0.2)
|
||||
rm = rm - pcr
|
||||
end
|
||||
|
||||
amount_fluid = amount_fluid + rm
|
||||
in_buffer.amount = in_buffer.amount - rm
|
||||
|
||||
if in_buffer.amount <= 0 then
|
||||
in_buffer.amount = 0
|
||||
in_buffer.fluid = ""
|
||||
end
|
||||
end
|
||||
|
||||
out_buffer.amount = out_buffer.amount + amount_fluid
|
||||
if out_buffer.amount > out_buffer.capacity then
|
||||
out_buffer.amount = out_buffer.capacity
|
||||
@ -89,6 +113,9 @@ local function on_timer(pos, elapsed)
|
||||
|
||||
inv:set_list("src", list_new)
|
||||
|
||||
meta:set_int("input_fluid_storage", in_buffer.amount)
|
||||
meta:set_string("input_fluid", in_buffer.fluid)
|
||||
|
||||
meta:set_int("output_fluid_storage", out_buffer.amount)
|
||||
meta:set_string("output_fluid", "elepower_farming:biofuel_source")
|
||||
|
||||
@ -107,20 +134,30 @@ local function on_timer(pos, elapsed)
|
||||
meta:set_int("src_time", time)
|
||||
meta:set_int("src_time_max", time_max)
|
||||
|
||||
meta:set_string("formspec", get_formspec(timer, out_buffer))
|
||||
meta:set_string("formspec", get_formspec(timer, in_buffer, out_buffer))
|
||||
|
||||
return refresh
|
||||
end
|
||||
|
||||
ele.register_base_device("elepower_farming:composter", {
|
||||
description = "Composter\nConvert plant matter to Biofuel",
|
||||
description = "Composter\nConvert organic matter to Biofuel",
|
||||
groups = {oddly_breakable_by_hand = 1, cracky = 1, fluid_container = 1, tube = 1},
|
||||
fluid_buffers = {
|
||||
output = {
|
||||
capacity = 8000,
|
||||
drainable = true,
|
||||
},
|
||||
input = {
|
||||
capacity = 8000,
|
||||
drainable = false,
|
||||
accepts = {
|
||||
"group:raw_bio",
|
||||
"elepower_farming:biomass_source",
|
||||
"elepower_farming:tree_sap_source",
|
||||
"elepower_farming:sludge_source",
|
||||
}
|
||||
},
|
||||
},
|
||||
on_timer = on_timer,
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user