mirror of
https://github.com/sirrobzeroone/elepower.git
synced 2024-12-03 12:03:46 +01:00
Add a water accumulator node, disable fluid network caching temporarily
This commit is contained in:
parent
b11ec4a220
commit
8c1622c52a
@ -64,12 +64,12 @@ end
|
|||||||
local function fluid_targets(p_pos, positions)
|
local function fluid_targets(p_pos, positions)
|
||||||
local provider = minetest.get_node(p_pos)
|
local provider = minetest.get_node(p_pos)
|
||||||
local pnodeid = minetest.pos_to_string(p_pos)
|
local pnodeid = minetest.pos_to_string(p_pos)
|
||||||
|
--[[
|
||||||
if elefluid.graphcache[pnodeid] then
|
if elefluid.graphcache[pnodeid] then
|
||||||
local cached = elefluid.graphcache[pnodeid]
|
local cached = elefluid.graphcache[pnodeid]
|
||||||
return cached.targets
|
return cached.targets
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
local targets = {}
|
local targets = {}
|
||||||
local queue = {}
|
local queue = {}
|
||||||
local all_nodes = {}
|
local all_nodes = {}
|
||||||
@ -111,7 +111,7 @@ end
|
|||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:elefluid_transport_source"},
|
nodenames = {"group:elefluid_transport_source"},
|
||||||
label = "elefluitFluidGraphSource",
|
label = "elefluidFluidGraphSource",
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
@ -231,6 +231,11 @@ local function check_connections(pos)
|
|||||||
return connections
|
return connections
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function elefluid.clear_networks(pos)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
-- Update networks when a node has been placed or removed
|
-- Update networks when a node has been placed or removed
|
||||||
function elefluid.clear_networks(pos)
|
function elefluid.clear_networks(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
@ -313,3 +318,4 @@ function elefluid.clear_networks(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
@ -9,6 +9,7 @@ function elefluid.register_transfer_node(nodename, nodedef)
|
|||||||
|
|
||||||
nodedef.groups["elefluid_transport_source"] = 1
|
nodedef.groups["elefluid_transport_source"] = 1
|
||||||
nodedef.paramtype2 = "facedir"
|
nodedef.paramtype2 = "facedir"
|
||||||
|
nodedef.legacy_facedir_simple = true
|
||||||
|
|
||||||
local orig_construct = nodedef.on_construct
|
local orig_construct = nodedef.on_construct
|
||||||
nodedef.on_construct = function (pos)
|
nodedef.on_construct = function (pos)
|
||||||
|
@ -10,4 +10,5 @@ dofile(modpath.."/craft.lua")
|
|||||||
dofile(modpath.."/formspec.lua")
|
dofile(modpath.."/formspec.lua")
|
||||||
dofile(modpath.."/bases/init.lua")
|
dofile(modpath.."/bases/init.lua")
|
||||||
dofile(modpath.."/nodes.lua")
|
dofile(modpath.."/nodes.lua")
|
||||||
|
dofile(modpath.."/special/init.lua")
|
||||||
dofile(modpath.."/register.lua")
|
dofile(modpath.."/register.lua")
|
||||||
|
64
elepower_machines/special/accumulator.lua
Normal file
64
elepower_machines/special/accumulator.lua
Normal file
@ -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
|
||||||
|
})
|
2
elepower_machines/special/init.lua
Normal file
2
elepower_machines/special/init.lua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
dofile(elepm.modpath.."/special/accumulator.lua")
|
BIN
elepower_machines/textures/elepower_machine_accumulator.png
Normal file
BIN
elepower_machines/textures/elepower_machine_accumulator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
Loading…
Reference in New Issue
Block a user