From a5c62ce1803bd957767c46551c3db1a6fd96656f Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 10 Feb 2019 18:56:24 +0200 Subject: [PATCH] Evaporator --- elepower_machines/crafting.lua | 10 ++ elepower_machines/machines/evaporator.lua | 146 ++++++++++++++++++ elepower_machines/machines/init.lua | 1 + .../elepower_machine_vaporidenser.png | Bin 0 -> 344 bytes ...elepower_machine_vaporidenser_animated.png | Bin 0 -> 363 bytes 5 files changed, 157 insertions(+) create mode 100644 elepower_machines/machines/evaporator.lua create mode 100644 elepower_machines/textures/elepower_machine_vaporidenser.png create mode 100644 elepower_machines/textures/elepower_machine_vaporidenser_animated.png diff --git a/elepower_machines/crafting.lua b/elepower_machines/crafting.lua index f18f711..dc7d8fc 100644 --- a/elepower_machines/crafting.lua +++ b/elepower_machines/crafting.lua @@ -718,3 +718,13 @@ minetest.register_craft({ {"elepower_dynamics:invar_gear", "elepower_dynamics:steel_plate", "elepower_dynamics:invar_gear"}, } }) + +-- Evaporizer +minetest.register_craft({ + output = "elepower_machines:evaporator", + recipe = { + {"elepower_dynamics:steel_plate", "default:steelblock", "elepower_dynamics:steel_plate"}, + {"elepower_dynamics:steel_plate", "elepower_machines:machine_block", "elepower_dynamics:steel_plate"}, + {"elepower_dynamics:induction_coil", "elepower_dynamics:zinc_plate", "elepower_dynamics:induction_coil"}, + } +}) diff --git a/elepower_machines/machines/evaporator.lua b/elepower_machines/machines/evaporator.lua new file mode 100644 index 0000000..c37af7d --- /dev/null +++ b/elepower_machines/machines/evaporator.lua @@ -0,0 +1,146 @@ + +local function get_formspec(power, input, output, state) + return "size[8,8.5]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + ele.formspec.power_meter(power).. + ele.formspec.state_switcher(3.5, 1, state).. + ele.formspec.fluid_bar(1, 0, input).. + ele.formspec.fluid_bar(7, 0, output).. + "image[3.5,2;1,1;gui_furnace_arrow_bg.png^[transformR270]".. + "list[current_player;main;0,4.25;8,1;]".. + "list[current_player;main;0,5.5;8,3;8]".. + "listring[current_player;main]".. + "listring[context;src]".. + "listring[current_player;main]".. + "listring[context;dst]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.25) +end + +local function on_timer(pos, elapsed) + local refresh = false + local meta = minetest.get_meta(pos) + + local input = fluid_lib.get_buffer_data(pos, "input") + local output = fluid_lib.get_buffer_data(pos, "output") + local state = meta:get_int("state") + + local is_enabled = ele.helpers.state_enabled(meta, pos, state) + + local capacity = ele.helpers.get_node_property(meta, pos, "capacity") + local usage = ele.helpers.get_node_property(meta, pos, "usage") + local storage = ele.helpers.get_node_property(meta, pos, "storage") + local pow_buffer = {capacity = capacity, storage = storage, usage = 0} + + local efficiency = 0.8 + local status = "Idle" + + while true do + if not is_enabled then + status = "Off" + break + end + + if pow_buffer.storage < usage then + status = "Out of Power!" + break + end + + if input.fluid == "" or input.amount == 0 then + break + end + + local fdef = minetest.registered_nodes[input.fluid] + if not fdef["gas_form"] then + break + end + + local inp = input.amount + if inp > 100 then inp = 100 end + local outp = math.floor(inp * efficiency) + + if (output.amount + outp > output.capacity) or (output.fluid ~= "" and output.fluid ~= fdef["gas_form"]) then + break + end + + status = "Active" + pow_buffer.usage = usage + pow_buffer.storage = pow_buffer.storage - usage + output.amount = output.amount + outp + output.fluid = fdef["gas_form"] + input.amount = input.amount - inp + refresh = true + + if input.amount == 0 then + input.fluid = "" + end + + break + end + + if refresh then + ele.helpers.swap_node(pos, "elepower_machines:evaporator_active") + else + ele.helpers.swap_node(pos, "elepower_machines:evaporator") + end + + meta:set_int("input_fluid_storage", input.amount) + meta:set_string("input_fluid", input.fluid) + + meta:set_int("output_fluid_storage", output.amount) + meta:set_string("output_fluid", output.fluid) + + meta:set_int("storage", pow_buffer.storage) + + meta:set_string("infotext", ("Evaporator %s\n%s"):format(status, ele.capacity_text(pow_buffer.capacity, pow_buffer.storage))) + meta:set_string("formspec", get_formspec(pow_buffer, input, output, state)) + + return refresh +end + +local animated = { + name = "elepower_machine_vaporidenser_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 2.0, + } +} + +ele.register_machine("elepower_machines:evaporator", { + description = "Evaporator", + groups = {oddly_breakable_by_hand = 1, cracky = 1, fluid_container = 1, ele_user = 1}, + fluid_buffers = { + input = { + capacity = 8000, + accepts = {"group:liquid"}, + drainable = false, + }, + output = { + capacity = 8000, + accepts = false, + drainable = true, + }, + }, + on_timer = on_timer, + on_construct = function (pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", get_formspec()) + end, + tiles = { + "elepower_machine_top.png^elepower_power_port.png", "elepower_machine_base.png^elepower_power_port.png", + "elepower_machine_vaporidenser.png", + }, + ele_active_node = true, + ele_no_automatic_ports = true, + ele_active_nodedef = { + tiles = { + "elepower_machine_top.png^elepower_power_port.png", "elepower_machine_base.png^elepower_power_port.png", animated, + }, + }, + ele_usage = 128, + on_receive_fields = get_fields, +}) diff --git a/elepower_machines/machines/init.lua b/elepower_machines/machines/init.lua index ab39edf..f11c2eb 100644 --- a/elepower_machines/machines/init.lua +++ b/elepower_machines/machines/init.lua @@ -27,6 +27,7 @@ dofile(mp .. "solderer.lua") dofile(mp .. "compressor.lua") dofile(mp .. "canning_machine.lua") dofile(mp .. "electrolyzer.lua") +dofile(mp .. "evaporator.lua") -- Other dofile(mp .. "accumulator.lua") diff --git a/elepower_machines/textures/elepower_machine_vaporidenser.png b/elepower_machines/textures/elepower_machine_vaporidenser.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae52764948945546257220c8c53c0c4a416ae1f GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggwCQcqjZqM1TGJ!&}nIRD+&iT2y zsd*(pE(3#eQEFmIYKlU6W=V#EyQgnJie4%^P<*|oi(`nz>9>=u^A0=kxZHo!6)Uy; zn(iC#7hF5-m$y!7(pch~1>E?s;1 zN>t`;F$T|;MSJc$Gs?6zx(U_Z&%YAQZ+mun>cKM+*QZv_J82p0l{ic7Oi$3M{gsbg z_cG=)H1x%*`>W_kKi$rdaFgNPw_35Rf**e@9yr!~=yKO5+Ij>!MP|ku_QG` zp**uBL&4qCHy}kXl^rO4#nZ(x#N+te$s6+y8}PWiSGgEGoy|l2zw2+|f35%Q-yCJ+ z*)7YnGlh+S0}{NK0W;Nm-ng9_&AO8AN?>@V|e`i<)?^estGK$)3U2(_w^q;ye&6; zZ@HOFL-g`#>py)sV`Ji5e6>3LFyoHWte;x^|BoJ)6fg8>_EC1*3i7z8tDnm{r-UW| D&UK8s literal 0 HcmV?d00001