From 18bc34b28f6a6443be98afe2f97e3cde7c74b2a9 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 12 Aug 2018 15:42:32 +0300 Subject: [PATCH] Liquid Fuel Burner --- elepower_machines/craft.lua | 2 +- elepower_machines/crafting.lua | 10 +++++ elepower_machines/machines/bases/crafter.lua | 8 ++-- ...fluidgenerator.lua => fluid_generator.lua} | 39 ++++++++++-------- .../machines/bases/generator.lua | 8 ++-- elepower_machines/machines/bases/init.lua | 2 +- elepower_machines/machines/fuel_burner.lua | 27 ++++++++++++ elepower_machines/machines/init.lua | 1 + .../textures/elepower_fuel_generator.png | Bin 0 -> 6887 bytes .../elepower_fuel_generator_active.png | Bin 0 -> 7048 bytes 10 files changed, 70 insertions(+), 27 deletions(-) rename elepower_machines/machines/bases/{fluidgenerator.lua => fluid_generator.lua} (81%) create mode 100644 elepower_machines/machines/fuel_burner.lua create mode 100644 elepower_machines/textures/elepower_fuel_generator.png create mode 100644 elepower_machines/textures/elepower_fuel_generator_active.png diff --git a/elepower_machines/craft.lua b/elepower_machines/craft.lua index ecf0e17..c69738d 100644 --- a/elepower_machines/craft.lua +++ b/elepower_machines/craft.lua @@ -18,7 +18,7 @@ function elepm.register_craft(craftdef) return nil end - if craftdef.type == "cooking" then + if craftdef.type == "cooking" or craftdef.type == "fuel" then minetest.register_craft(craftdef) return end diff --git a/elepower_machines/crafting.lua b/elepower_machines/crafting.lua index f02bd69..3c8f468 100644 --- a/elepower_machines/crafting.lua +++ b/elepower_machines/crafting.lua @@ -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 minetest.register_craft({ output = "elepower_machines:alloy_furnace", diff --git a/elepower_machines/machines/bases/crafter.lua b/elepower_machines/machines/bases/crafter.lua index 1df7352..73bac83 100644 --- a/elepower_machines/machines/bases/crafter.lua +++ b/elepower_machines/machines/bases/crafter.lua @@ -113,7 +113,7 @@ function elepm.register_crafter(nodename, nodedef) -- Determine if there is enough power for this action 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 pow_buffer.usage = usage end @@ -135,9 +135,7 @@ function elepm.register_crafter(nodename, nodedef) status = "Active" -- One step - storage = storage - usage - meta:set_int("storage", storage) - pow_buffer = {capacity = capacity, storage = storage, usage = usage} + pow_buffer.storage = pow_buffer.storage - usage time = time + ele.helpers.round(machine_speed * 10) 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("infotext", ("%s %s"):format(nodedef.description, status) .. "\n" .. ele.capacity_text(capacity, storage)) + meta:set_int("src_time", time) + meta:set_int("storage", pow_buffer.storage) return refresh end diff --git a/elepower_machines/machines/bases/fluidgenerator.lua b/elepower_machines/machines/bases/fluid_generator.lua similarity index 81% rename from elepower_machines/machines/bases/fluidgenerator.lua rename to elepower_machines/machines/bases/fluid_generator.lua index e1a4fe9..c73af2a 100644 --- a/elepower_machines/machines/bases/fluidgenerator.lua +++ b/elepower_machines/machines/bases/fluid_generator.lua @@ -16,20 +16,14 @@ end -- A generator that creates power using a fuel function ele.register_fluid_generator(nodename, nodedef) - local fuel = nodedef.fuel - local btime = nodedef.fuel_burn_time or 60 - + local btime = nodedef.fuel_burn_time or 8 + local busage = nodedef.fuel_usage or 1000 local buffer_name = nil -- Autodetect fluid buffer and the fuel if necessary if not nodedef.fluid_buffers then return nil end for buf,data in pairs(nodedef.fluid_buffers) do buffer_name = buf - - if not fuel and data.accepts and type(data.accepts) == "table" then - fuel = data.accepts[1] - end - break end @@ -68,7 +62,6 @@ function ele.register_fluid_generator(nodename, nodedef) local status = "Idle" while true do - if not flbuffer or flbuffer.fluid == "" then break end if not is_enabled then status = "Off" break @@ -80,28 +73,38 @@ function ele.register_fluid_generator(nodename, nodedef) break end - storage = storage + generation - meta:set_int("storage", storage) + pow_buffer.storage = pow_buffer.storage + generation + pow_buffer.usage = generation burn_time = burn_time - 1 meta:set_int("burn_time", burn_time) + + refresh = true end status = "Active" -- Burn another bucket of lava if burn_time == 0 then + if not flbuffer or flbuffer.fluid == "" then break end + 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_totaltime", btime) -- Take lava - flbuffer.amount = flbuffer.amount - 1000 + flbuffer.amount = flbuffer.amount - busage pow_buffer.usage = generation - local active_node = nodename.."_active" - ele.helpers.swap_node(pos, active_node) + if nodedef.ele_active_node then + 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) + end refresh = true else @@ -116,9 +119,10 @@ function ele.register_fluid_generator(nodename, nodedef) local percent = math.floor((burn_time / burn_totaltime) * 100) 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, - 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("storage", pow_buffer.storage) return refresh end, @@ -132,7 +136,8 @@ function ele.register_fluid_generator(nodename, nodedef) end } - nodedef.fuel = nil + nodedef.fuel_burn_time = nil + nodedef.fuel_usage = nil for key,val in pairs(defaults) do if not nodedef[key] then diff --git a/elepower_machines/machines/bases/generator.lua b/elepower_machines/machines/bases/generator.lua index bb5d349..c344fce 100644 --- a/elepower_machines/machines/bases/generator.lua +++ b/elepower_machines/machines/bases/generator.lua @@ -63,10 +63,8 @@ function elepm.register_fuel_generator(nodename, nodedef) return false end - storage = storage + generation - pow_buffer.storage = storage + pow_buffer.storage = pow_buffer.storage + generation pow_buffer.usage = generation - meta:set_int("storage", storage) burn_time = burn_time - 1 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) meta:set_string("formspec", get_formspec(pow_buffer, percent, state)) 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 end diff --git a/elepower_machines/machines/bases/init.lua b/elepower_machines/machines/bases/init.lua index 2a7aad0..77427ed 100644 --- a/elepower_machines/machines/bases/init.lua +++ b/elepower_machines/machines/bases/init.lua @@ -1,5 +1,5 @@ dofile(elepm.modpath.."/machines/bases/crafter.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") diff --git a/elepower_machines/machines/fuel_burner.lua b/elepower_machines/machines/fuel_burner.lua new file mode 100644 index 0000000..6d37811 --- /dev/null +++ b/elepower_machines/machines/fuel_burner.lua @@ -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, +}) diff --git a/elepower_machines/machines/init.lua b/elepower_machines/machines/init.lua index 07415e9..7ebbc04 100644 --- a/elepower_machines/machines/init.lua +++ b/elepower_machines/machines/init.lua @@ -8,6 +8,7 @@ dofile(mp .. "bases/init.lua") dofile(mp .. "generator.lua") dofile(mp .. "lava_generator.lua") dofile(mp .. "steam_turbine.lua") +dofile(mp .. "fuel_burner.lua") -- Storage dofile(mp .. "storage.lua") diff --git a/elepower_machines/textures/elepower_fuel_generator.png b/elepower_machines/textures/elepower_fuel_generator.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b5a7e78f4a2a8985911d16064f036a1d8be11d GIT binary patch literal 6887 zcmeHL2UHZ-8eT+-2neErN@QF$*4a8+W?@B|fJ%`f8WotG0xR3xUDyRQq7dwjAU28y zMbwB!ETFN#3m8RIVj{5+E5+WhAeMJ`A&Bq!%=4V&oa7wg%$9Y=$=VQ12dUIbN-85EZK8^VNWGMz z(exK~M98zQ53_!GdiYaIKgjM_S<2=0{qH>7|6DyZFh=w^;m)!$&kY&ly6l&}c`d4T zFInT(pE=RXs_fdM<3mq173M??2-^LnTkYbyoS~(q=1%na=c*%Y#{UMzG(FB(y*Ds@ z+JHXeHjH?Q0+ zQ(LaCAKG$!^}@wy@lDs$+ZxXo=+0Y|IA?`kTve0$TTMQXGP`8&{@sPty8CHUC-yYc zP8xiE?!jQX`O=|@+cIx%;$QGIvl9!J#jfq{I>Ox3tnb3A4HuuS4_wA5wYqS=_omd; zOy(%$WC2#RqFgnE_oHpOCR5OOnQ6Gl@a`v zmUF}GGEH)F8cp}Cu#89{mhbL@7IyiyGTYB<)mK}b`VU-S=eT6?mCsA9cYp7ABdB?i z^NDLeEcRP5Y=pmBwJ~C{CA;}Ep0DHVOee{bexWDF<|OsD=@-tE24*`aO!F^1wrTk0 zYz)Ecmz?iwg}Tft`In12ZP0+EO@kcy6}_W2rS)8#6{fDgHR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D_A>Z|pcto2gL4ev^5?T_n_PO6QC4A1rv zb8Q`IG?Ns6Z;vox)vAosffvWvRn93M6~19(AG>bd8UvEH|2%Hxi|?JsTsz^ABFvA^ zKVjP|qZhh6CTUmguXC*)PEXJ!G_*G4ous%9_F=v4u~r4O=KPh@Xl;u=oD}7Bf#}}e zjjvtlJx?`iW)b(clT#|EF7P~sp0p0HP`ZLveMQUqu9pwLY4W3IFVHR-nD)lpbXsJ# zgJ;t?nrhpkZ9P4&JZ)I_OqHw&u-xeIXIzUvA$Nl*AjQ_o-SihlSkw=QS;=tYkTWd*9{7CY}@S!T&cdN?f|d*|-`(Ax0* zrt8&SrRR6$zQoilkMQBOLu^fw#&_9JP2_XZ{ItNwW8+%S?;=z7*1Rf?*bd#Oa+VJH=B~>$mnzr9%kkx4!D#+I Lf!;-)(ewTd$=>fI literal 0 HcmV?d00001 diff --git a/elepower_machines/textures/elepower_fuel_generator_active.png b/elepower_machines/textures/elepower_fuel_generator_active.png new file mode 100644 index 0000000000000000000000000000000000000000..163231ffdd70ee40993e4090dc241981222661e0 GIT binary patch literal 7048 zcmeHL2~-o;-VZ7Wh!!j^tcHjJwL>zK$qEsKP(ay4_98l&nLs3)Ng#pG1x1S@AnqI5 z2eu$u!IkHNSX@vP1&bmIYOByFAc_l$pna1-72oq~KhJqR=j%BpCz-kT{{FxFzyIyt znUx_yz9UVoO-UruNPj{|QfjLr5gUkkqg!RVbn+%M~)ANQ{$JDRP{Q zYeYg4Npo{=Wc0=sXR|)7rE-{~`NjEBciL@gx||wgw_L6%X=6zut-oAm>Fg*k?tWBS z@}}~vWmI%mrH>YNwUM+e3#x0M{?z~GW$mIXMNb_guams7x~Vt~TfHi8#hd(d zFQ(@=c6%wpZv`n|2gzDe2yu*D|BT-er3^Pm|pF zq|ecJR8J9OLPJ&Q3+q%_Vp28t%Nq}Uwtrt^|Ln<%hP+n!|Mc-QEIQ`$sNUCo_-i76`S85<)m zo_OupgR&XwTQBN%wmlF?>R%~-Ge|r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