Liquid Fuel Burner
This commit is contained in:
parent
ce47073b69
commit
18bc34b28f
@ -18,7 +18,7 @@ function elepm.register_craft(craftdef)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if craftdef.type == "cooking" then
|
if craftdef.type == "cooking" or craftdef.type == "fuel" then
|
||||||
minetest.register_craft(craftdef)
|
minetest.register_craft(craftdef)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -368,6 +368,16 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Liquid Fuel Combustion Generator
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "elepower_machines:fuel_burner",
|
||||||
|
recipe = {
|
||||||
|
{"elepower_dynamics:wound_copper_coil", "elepower_dynamics:integrated_circuit", "elepower_dynamics:wound_copper_coil"},
|
||||||
|
{"default:brick", "elepower_dynamics:portable_tank", "default:brick"},
|
||||||
|
{"elepower_dynamics:servo_valve", "elepower_machines:generator", "elepower_dynamics:servo_valve"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Alloy Furnace
|
-- Alloy Furnace
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "elepower_machines:alloy_furnace",
|
output = "elepower_machines:alloy_furnace",
|
||||||
|
@ -113,7 +113,7 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
|
|
||||||
-- Determine if there is enough power for this action
|
-- Determine if there is enough power for this action
|
||||||
res_time = result.time
|
res_time = result.time
|
||||||
if result.time ~= 0 and storage >= usage then
|
if result.time ~= 0 and pow_buffer.storage >= usage then
|
||||||
power_operation = true
|
power_operation = true
|
||||||
pow_buffer.usage = usage
|
pow_buffer.usage = usage
|
||||||
end
|
end
|
||||||
@ -135,9 +135,7 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
status = "Active"
|
status = "Active"
|
||||||
|
|
||||||
-- One step
|
-- One step
|
||||||
storage = storage - usage
|
pow_buffer.storage = pow_buffer.storage - usage
|
||||||
meta:set_int("storage", storage)
|
|
||||||
pow_buffer = {capacity = capacity, storage = storage, usage = usage}
|
|
||||||
time = time + ele.helpers.round(machine_speed * 10)
|
time = time + ele.helpers.round(machine_speed * 10)
|
||||||
|
|
||||||
if nodedef.ele_active_node then
|
if nodedef.ele_active_node then
|
||||||
@ -193,7 +191,9 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
meta:set_string("formspec", get_formspec(craft_type, pow_buffer, pct, pos, state))
|
meta:set_string("formspec", get_formspec(craft_type, pow_buffer, pct, pos, state))
|
||||||
meta:set_string("infotext", ("%s %s"):format(nodedef.description, status) ..
|
meta:set_string("infotext", ("%s %s"):format(nodedef.description, status) ..
|
||||||
"\n" .. ele.capacity_text(capacity, storage))
|
"\n" .. ele.capacity_text(capacity, storage))
|
||||||
|
|
||||||
meta:set_int("src_time", time)
|
meta:set_int("src_time", time)
|
||||||
|
meta:set_int("storage", pow_buffer.storage)
|
||||||
|
|
||||||
return refresh
|
return refresh
|
||||||
end
|
end
|
||||||
|
@ -16,20 +16,14 @@ end
|
|||||||
|
|
||||||
-- A generator that creates power using a fuel
|
-- A generator that creates power using a fuel
|
||||||
function ele.register_fluid_generator(nodename, nodedef)
|
function ele.register_fluid_generator(nodename, nodedef)
|
||||||
local fuel = nodedef.fuel
|
local btime = nodedef.fuel_burn_time or 8
|
||||||
local btime = nodedef.fuel_burn_time or 60
|
local busage = nodedef.fuel_usage or 1000
|
||||||
|
|
||||||
local buffer_name = nil
|
local buffer_name = nil
|
||||||
|
|
||||||
-- Autodetect fluid buffer and the fuel if necessary
|
-- Autodetect fluid buffer and the fuel if necessary
|
||||||
if not nodedef.fluid_buffers then return nil end
|
if not nodedef.fluid_buffers then return nil end
|
||||||
for buf,data in pairs(nodedef.fluid_buffers) do
|
for buf,data in pairs(nodedef.fluid_buffers) do
|
||||||
buffer_name = buf
|
buffer_name = buf
|
||||||
|
|
||||||
if not fuel and data.accepts and type(data.accepts) == "table" then
|
|
||||||
fuel = data.accepts[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,7 +62,6 @@ function ele.register_fluid_generator(nodename, nodedef)
|
|||||||
local status = "Idle"
|
local status = "Idle"
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
if not flbuffer or flbuffer.fluid == "" then break end
|
|
||||||
if not is_enabled then
|
if not is_enabled then
|
||||||
status = "Off"
|
status = "Off"
|
||||||
break
|
break
|
||||||
@ -80,28 +73,38 @@ function ele.register_fluid_generator(nodename, nodedef)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
storage = storage + generation
|
pow_buffer.storage = pow_buffer.storage + generation
|
||||||
meta:set_int("storage", storage)
|
pow_buffer.usage = generation
|
||||||
|
|
||||||
burn_time = burn_time - 1
|
burn_time = burn_time - 1
|
||||||
meta:set_int("burn_time", burn_time)
|
meta:set_int("burn_time", burn_time)
|
||||||
|
|
||||||
|
refresh = true
|
||||||
end
|
end
|
||||||
|
|
||||||
status = "Active"
|
status = "Active"
|
||||||
|
|
||||||
-- Burn another bucket of lava
|
-- Burn another bucket of lava
|
||||||
if burn_time == 0 then
|
if burn_time == 0 then
|
||||||
|
if not flbuffer or flbuffer.fluid == "" then break end
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if flbuffer.amount >= 1000 then
|
if flbuffer.amount >= busage then
|
||||||
meta:set_int("burn_time", btime)
|
meta:set_int("burn_time", btime)
|
||||||
meta:set_int("burn_totaltime", btime)
|
meta:set_int("burn_totaltime", btime)
|
||||||
|
|
||||||
-- Take lava
|
-- Take lava
|
||||||
flbuffer.amount = flbuffer.amount - 1000
|
flbuffer.amount = flbuffer.amount - busage
|
||||||
pow_buffer.usage = generation
|
pow_buffer.usage = generation
|
||||||
|
|
||||||
|
if nodedef.ele_active_node then
|
||||||
local active_node = nodename .. "_active"
|
local active_node = nodename .. "_active"
|
||||||
|
if nodedef.ele_active_node ~= true then
|
||||||
|
active_node = nodedef.ele_active_node
|
||||||
|
end
|
||||||
|
|
||||||
ele.helpers.swap_node(pos, active_node)
|
ele.helpers.swap_node(pos, active_node)
|
||||||
|
end
|
||||||
|
|
||||||
refresh = true
|
refresh = true
|
||||||
else
|
else
|
||||||
@ -116,9 +119,10 @@ function ele.register_fluid_generator(nodename, nodedef)
|
|||||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||||
meta:set_string("formspec", get_formspec(pow_buffer, percent, flbuffer, state))
|
meta:set_string("formspec", get_formspec(pow_buffer, percent, flbuffer, state))
|
||||||
meta:set_string("infotext", ("%s %s\n%s\n%s"):format(nodedef.description, status,
|
meta:set_string("infotext", ("%s %s\n%s\n%s"):format(nodedef.description, status,
|
||||||
ele.capacity_text(capacity, storage), fluid_lib.buffer_to_string(flbuffer)))
|
ele.capacity_text(capacity, pow_buffer.storage), fluid_lib.buffer_to_string(flbuffer)))
|
||||||
|
|
||||||
meta:set_int(buffer_name .. "_fluid_storage", flbuffer.amount)
|
meta:set_int(buffer_name .. "_fluid_storage", flbuffer.amount)
|
||||||
|
meta:set_int("storage", pow_buffer.storage)
|
||||||
|
|
||||||
return refresh
|
return refresh
|
||||||
end,
|
end,
|
||||||
@ -132,7 +136,8 @@ function ele.register_fluid_generator(nodename, nodedef)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
nodedef.fuel = nil
|
nodedef.fuel_burn_time = nil
|
||||||
|
nodedef.fuel_usage = nil
|
||||||
|
|
||||||
for key,val in pairs(defaults) do
|
for key,val in pairs(defaults) do
|
||||||
if not nodedef[key] then
|
if not nodedef[key] then
|
@ -63,10 +63,8 @@ function elepm.register_fuel_generator(nodename, nodedef)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
storage = storage + generation
|
pow_buffer.storage = pow_buffer.storage + generation
|
||||||
pow_buffer.storage = storage
|
|
||||||
pow_buffer.usage = generation
|
pow_buffer.usage = generation
|
||||||
meta:set_int("storage", storage)
|
|
||||||
|
|
||||||
burn_time = burn_time - 1
|
burn_time = burn_time - 1
|
||||||
meta:set_int("burn_time", burn_time)
|
meta:set_int("burn_time", burn_time)
|
||||||
@ -113,7 +111,9 @@ function elepm.register_fuel_generator(nodename, nodedef)
|
|||||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||||
meta:set_string("formspec", get_formspec(pow_buffer, percent, state))
|
meta:set_string("formspec", get_formspec(pow_buffer, percent, state))
|
||||||
meta:set_string("infotext", ("%s %s"):format(nodedef.description, status) ..
|
meta:set_string("infotext", ("%s %s"):format(nodedef.description, status) ..
|
||||||
"\n" .. ele.capacity_text(capacity, storage))
|
"\n" .. ele.capacity_text(capacity, pow_buffer.storage))
|
||||||
|
|
||||||
|
meta:set_int("storage", pow_buffer.storage)
|
||||||
|
|
||||||
return refresh
|
return refresh
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
dofile(elepm.modpath.."/machines/bases/crafter.lua")
|
dofile(elepm.modpath.."/machines/bases/crafter.lua")
|
||||||
dofile(elepm.modpath.."/machines/bases/generator.lua")
|
dofile(elepm.modpath.."/machines/bases/generator.lua")
|
||||||
dofile(elepm.modpath.."/machines/bases/fluidgenerator.lua")
|
dofile(elepm.modpath.."/machines/bases/fluid_generator.lua")
|
||||||
dofile(elepm.modpath.."/machines/bases/storage.lua")
|
dofile(elepm.modpath.."/machines/bases/storage.lua")
|
||||||
|
27
elepower_machines/machines/fuel_burner.lua
Normal file
27
elepower_machines/machines/fuel_burner.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
ele.register_fluid_generator("elepower_machines:fuel_burner", {
|
||||||
|
description = "Liquid Fuel Combustion Generator",
|
||||||
|
ele_usage = 8,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_fuel_generator.png",
|
||||||
|
},
|
||||||
|
ele_active_node = true,
|
||||||
|
ele_active_nodedef = {
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_fuel_generator_active.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fluid_buffers = {
|
||||||
|
steam = {
|
||||||
|
capacity = 8000,
|
||||||
|
drainable = false,
|
||||||
|
accepts = {
|
||||||
|
"elepower_farming:biofuel_source",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fuel_burn_time = 4,
|
||||||
|
fuel_usage = 100,
|
||||||
|
})
|
@ -8,6 +8,7 @@ dofile(mp .. "bases/init.lua")
|
|||||||
dofile(mp .. "generator.lua")
|
dofile(mp .. "generator.lua")
|
||||||
dofile(mp .. "lava_generator.lua")
|
dofile(mp .. "lava_generator.lua")
|
||||||
dofile(mp .. "steam_turbine.lua")
|
dofile(mp .. "steam_turbine.lua")
|
||||||
|
dofile(mp .. "fuel_burner.lua")
|
||||||
|
|
||||||
-- Storage
|
-- Storage
|
||||||
dofile(mp .. "storage.lua")
|
dofile(mp .. "storage.lua")
|
||||||
|
BIN
elepower_machines/textures/elepower_fuel_generator.png
Normal file
BIN
elepower_machines/textures/elepower_fuel_generator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
elepower_machines/textures/elepower_fuel_generator_active.png
Normal file
BIN
elepower_machines/textures/elepower_fuel_generator_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
Loading…
Reference in New Issue
Block a user