From 8c1622c52aca3ee6030ff3e296db1247d213f5da Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 19 Jun 2018 10:16:43 +0300 Subject: [PATCH] Add a water accumulator node, disable fluid network caching temporarily --- elepower_fapi/transfer.lua | 12 +++- elepower_fapi/transfer_node.lua | 1 + elepower_machines/init.lua | 1 + elepower_machines/special/accumulator.lua | 64 ++++++++++++++++++ elepower_machines/special/init.lua | 2 + .../textures/elepower_machine_accumulator.png | Bin 0 -> 6472 bytes 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 elepower_machines/special/accumulator.lua create mode 100644 elepower_machines/special/init.lua create mode 100644 elepower_machines/textures/elepower_machine_accumulator.png diff --git a/elepower_fapi/transfer.lua b/elepower_fapi/transfer.lua index ab1eb38..84b8874 100644 --- a/elepower_fapi/transfer.lua +++ b/elepower_fapi/transfer.lua @@ -64,12 +64,12 @@ end local function fluid_targets(p_pos, positions) local provider = minetest.get_node(p_pos) local pnodeid = minetest.pos_to_string(p_pos) - +--[[ if elefluid.graphcache[pnodeid] then local cached = elefluid.graphcache[pnodeid] return cached.targets end - +]] local targets = {} local queue = {} local all_nodes = {} @@ -111,7 +111,7 @@ end minetest.register_abm({ nodenames = {"group:elefluid_transport_source"}, - label = "elefluitFluidGraphSource", + label = "elefluidFluidGraphSource", interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) @@ -231,6 +231,11 @@ local function check_connections(pos) return connections end +function elefluid.clear_networks(pos) + return +end + +--[[ -- Update networks when a node has been placed or removed function elefluid.clear_networks(pos) local node = minetest.get_node(pos) @@ -313,3 +318,4 @@ function elefluid.clear_networks(pos) end end end +]] diff --git a/elepower_fapi/transfer_node.lua b/elepower_fapi/transfer_node.lua index 3fc3338..3f8405c 100644 --- a/elepower_fapi/transfer_node.lua +++ b/elepower_fapi/transfer_node.lua @@ -9,6 +9,7 @@ function elefluid.register_transfer_node(nodename, nodedef) nodedef.groups["elefluid_transport_source"] = 1 nodedef.paramtype2 = "facedir" + nodedef.legacy_facedir_simple = true local orig_construct = nodedef.on_construct nodedef.on_construct = function (pos) diff --git a/elepower_machines/init.lua b/elepower_machines/init.lua index 526488e..88a9f46 100644 --- a/elepower_machines/init.lua +++ b/elepower_machines/init.lua @@ -10,4 +10,5 @@ dofile(modpath.."/craft.lua") dofile(modpath.."/formspec.lua") dofile(modpath.."/bases/init.lua") dofile(modpath.."/nodes.lua") +dofile(modpath.."/special/init.lua") dofile(modpath.."/register.lua") diff --git a/elepower_machines/special/accumulator.lua b/elepower_machines/special/accumulator.lua new file mode 100644 index 0000000..31d9ec2 --- /dev/null +++ b/elepower_machines/special/accumulator.lua @@ -0,0 +1,64 @@ + +local CAPACITY = 8000 + +minetest.register_node("elepower_machines:accumulator", { + description = "Water Accumulator", + groups = {fluid_container = 1, oddly_breakable_by_hand = 1, cracky = 1}, + tiles = { + "elepower_machine_top.png^elepower_power_port.png", "elepower_machine_base.png", "elepower_machine_accumulator.png", + "elepower_machine_accumulator.png", "elepower_machine_accumulator.png", "elepower_machine_accumulator.png", + }, + fluid_buffers = { + water = { + capacity = CAPACITY + } + }, + on_construct = function ( pos ) + local meta = minetest.get_meta(pos) + meta:set_string("water_fluid", "default:water_source") + end +}) + +minetest.register_abm({ + nodenames = {"elepower_machines:accumulator"}, + label = "elefluidAccumulator", + interval = 2, + chance = 1/5, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.get_meta(pos) + local water_c = meta:get_int("water_fluid_storage") + if water_c == CAPACITY then return end + + local positions = { + {x=pos.x+1,y=pos.y,z=pos.z}, + {x=pos.x-1,y=pos.y,z=pos.z}, + {x=pos.x, y=pos.y,z=pos.z+1}, + {x=pos.x, y=pos.y,z=pos.z-1}, + } + + local fluid = 0 + for _,fpos in pairs(positions) do + local node = minetest.get_node(fpos) + if node.name == "default:water_source" then + fluid = fluid + 1000 + end + end + + if fluid == 0 then + meta:set_string("infotext", "Submerge me in water!") + return + end + + local give = 0 + if water_c + fluid > CAPACITY then + give = CAPACITY - water_c + else + give = fluid + end + + water_c = water_c + give + + meta:set_int("water_fluid_storage", water_c) + meta:set_string("infotext", ("Water: %d/%d %s"):format(water_c, CAPACITY, elefluid.unit)) + end +}) diff --git a/elepower_machines/special/init.lua b/elepower_machines/special/init.lua new file mode 100644 index 0000000..4b085c8 --- /dev/null +++ b/elepower_machines/special/init.lua @@ -0,0 +1,2 @@ + +dofile(elepm.modpath.."/special/accumulator.lua") diff --git a/elepower_machines/textures/elepower_machine_accumulator.png b/elepower_machines/textures/elepower_machine_accumulator.png new file mode 100644 index 0000000000000000000000000000000000000000..dc19d2e190364a5baae2801ed3da6183166ede69 GIT binary patch literal 6472 zcmeHL2~-o;8V=O5RTM=;R3rugeL6`d`$Ph=2`HQFh>DZR42)zmnGiszD5%8>s8tbM zP&{gJp;GGt6crFrq|_d@TDK~o^02spR4wY82^8@?pM9Rwp7VN+a00pae*bs>``!Ql z@14mG3G%hH7;QnL(JcM_yhF+VR@BGLg#7E!`3k1d2CYmDk0wH4JzcF)VYnQn6Dewx zjwa(6jh1|6f0UxI(|K^uS7BXde$Abt`Hh`jCX!E02M7I_tv}e2=wfo#b2K(6DB;!J z2h$hdva)uJu`Le1F=njbrwMjj5^^2$CXbm~+IebUlkL8s=E+1%;|k@X}8^TxpeDJG!>1sx0Ha&fyNY4X+@!HcVDZV4yy zpVuw0df;mM`Cc3ArNM2!pdjPOl_d*CJ^SAK(xTa=#sObX-di0Z_WU?4r|^f=IWg90 ztDL(!j_wKS-o9bAdE4%~d%xD}Pvag%YZtHS`sGp13x9lcR;g*~tkXpuu~REoY}x8$ zUm-!eUpDsC&1)!V4$s|?w*TVgE1xzpWAi5c29@yF|BxB?PkGL)aq%ZE6&5B4yUMbLOwIay%nwJ^Z58*~mERGgig+ zu_Gd(vWI?~rdQ-R4v)&sYKI3QgP+B@q&Huf9T(E*ymgLIepiFZ%F?l1yX9j>+!FZf zGH>eU<(2OB^bjWGZk#XJ>6_70_h`pa!fd~qNXXNj+}=dnW@a|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