diff options
| author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-30 20:16:00 +0100 | 
|---|---|---|
| committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-30 21:27:50 +0100 | 
| commit | 40eeaac2ecb25dbc55f7315342e74723d6248534 (patch) | |
| tree | c01da4e9ac67d84b372a69ef3b781020afb68af5 /register_flow_logic.lua | |
| parent | 10221c6c153e4d20bf1d289fe218d29477400a4d (diff) | |
internal refactoring of flowable node registration in preparation for enhanced flow checking logic
Diffstat (limited to 'register_flow_logic.lua')
| -rw-r--r-- | register_flow_logic.lua | 40 | 
1 files changed, 18 insertions, 22 deletions
| diff --git a/register_flow_logic.lua b/register_flow_logic.lua index c9df09c..8580188 100644 --- a/register_flow_logic.lua +++ b/register_flow_logic.lua @@ -1,29 +1,11 @@  -- register new flow logic ABMs  -- written 2017 by thetaepsilon -local pipes_full_nodenames = pipeworks.pipes_full_nodenames -local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames - --- run pressure balancing ABM over all water-moving nodes --- FIXME: DRY principle, get this from elsewhere in the code -local pump_on = "pipeworks:pump_on" -local pump_off = "pipeworks:pump_off" -local spigot_off = "pipeworks:spigot" -local spigot_on = "pipeworks:spigot_pouring" - -local pipes_all_nodenames = pipes_full_nodenames -for _, pipe in ipairs(pipes_empty_nodenames) do -	table.insert(pipes_all_nodenames, pipe) -end - -if pipeworks.enable_pipe_devices then -	table.insert(pipes_all_nodenames, pump_off) -	table.insert(pipes_all_nodenames, pump_on) -	table.insert(pipes_all_nodenames, spigot_on) -	table.insert(pipes_all_nodenames, spigot_off) -end +-- note that checking for feature toggles (because otherwise certain pipes aren't define) +-- is now done by flowable_nodes_add_pipes.lua +--[[  if pipeworks.enable_pipes then  	minetest.register_abm({  		nodenames = pipes_all_nodenames, @@ -34,19 +16,32 @@ if pipeworks.enable_pipes then  		end  	})  end +]] +-- flowables.register.simple takes care of creating an array-like table of node names +minetest.register_abm({ +	nodenames = pipeworks.flowables.list.simple_nodenames, +	interval = 1, +	chance = 1, +	action = function(pos, node, active_object_count, active_object_count_wider) +		pipeworks.balance_pressure(pos, node) +	end +})  if pipeworks.enable_pipe_devices then  	-- absorb water into pumps if it'll fit  	minetest.register_abm({ -		nodenames = { pump_on }, +		nodenames = pipeworks.flowables.inputs.nodenames,  		interval = 1,  		chance = 1,  		action = function(pos, node, active_object_count, active_object_count_wider)  			pipeworks.run_pump_intake(pos, node)  		end  	}) +  	-- output water from spigots  	-- add both "on/off" spigots so one can be used to indicate a certain level of fluid. +	-- temp. disabled as the node names were moved to flowable_node_add_pipes.lua +	--[[  	minetest.register_abm({  		nodenames = { spigot_on, spigot_off },  		interval = 1, @@ -55,4 +50,5 @@ if pipeworks.enable_pipe_devices then  			pipeworks.run_spigot_output(pos, node)  		end  	}) +	]]  end | 
