1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-26 02:40:23 +01:00

refactor pressure logic toggle to act as option enum

This commit is contained in:
thetaepsilon-gamedev 2017-10-20 22:46:51 +01:00
parent 538e33c537
commit 75978a0207
5 changed files with 17 additions and 15 deletions

View File

@ -29,16 +29,22 @@ local settings = {
delete_item_on_clearobject = true, delete_item_on_clearobject = true,
} }
pipeworks.toggles = {}
-- documentation for toggles controlling pressure logic features. -- documentation for toggles controlling pressure logic features.
-- do not edit this file directly; -- do not edit this file directly;
-- instead, create pipeworks_settings.txt in your world directory, -- instead, create pipeworks_settings.txt in your world directory,
-- and copy the uncommented lines from the block comment below into it. -- and copy the uncommented lines from the block comments below into it.
--[[
-- flow logic implementation.
-- set to one of the following strings.
-- "classic": classic mode written by VanessaE
-- "pressure": pressure metadata based, written by thetaepsilon.
-- has caveats such as water speed issues though.
-- setting to nil inhibits all flow logic, useful for debugging ABM crashes,
-- or for rendering the pipes purely decorative.
]]
pipeworks.toggles.pipe_mode = "classic"
--[[ --[[
-- enable pressure logic mode instead of "classic" mode.
-- WARNING: this changes a few things, most noticeably how pumps work.
-- you'll want to make sure they're fed by an infinite spring.
pipeworks.toggles.pressure_logic = true
-- force-enable finite water handling mode. -- force-enable finite water handling mode.
-- this changes the way that water node placement is handled; -- this changes the way that water node placement is handled;
-- volume will always be preserved, -- volume will always be preserved,

View File

@ -15,17 +15,13 @@ pipeworks.modpath = minetest.get_modpath("pipeworks")
dofile(pipeworks.modpath.."/default_settings.lua") dofile(pipeworks.modpath.."/default_settings.lua")
-- Read the external config file if it exists. -- Read the external config file if it exists.
-- please add any new feature toggles to be a flag in this table...
pipeworks.toggles = {}
local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt" local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt"
local worldsettingsfile = io.open(worldsettingspath, "r") local worldsettingsfile = io.open(worldsettingspath, "r")
if worldsettingsfile then if worldsettingsfile then
worldsettingsfile:close() worldsettingsfile:close()
dofile(worldsettingspath) dofile(worldsettingspath)
end end
if pipeworks.toggles.pressure_logic then if pipeworks.toggles.pipe_mode == "pressure" then
minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!") minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
end end

View File

@ -213,7 +213,7 @@ pipeworks.pipes_empty_nodenames = pipes_empty_nodenames
if not pipeworks.toggles.pressure_logic then if pipeworks.toggles.pipe_mode == "classic" then

View File

@ -10,7 +10,7 @@ local flowlogic = pipeworks.flowlogic
-- see flowlogic.run() in abms.lua. -- see flowlogic.run() in abms.lua.
local register_flowlogic_abm = function(nodename) local register_flowlogic_abm = function(nodename)
if pipeworks.toggles.pressure_logic then if pipeworks.toggles.pipe_mode == "pressure" then
minetest.register_abm({ minetest.register_abm({
label = "pipeworks new_flow_logic run", label = "pipeworks new_flow_logic run",
nodenames = { nodename }, nodenames = { nodename },

View File

@ -20,14 +20,14 @@ local insertbase = function(nodename)
if checkexists(nodename) then error("pipeworks.flowables duplicate registration!") end if checkexists(nodename) then error("pipeworks.flowables duplicate registration!") end
pipeworks.flowables.list.all[nodename] = true pipeworks.flowables.list.all[nodename] = true
-- table.insert(pipeworks.flowables.list.nodenames, nodename) -- table.insert(pipeworks.flowables.list.nodenames, nodename)
if pipeworks.toggles.pressure_logic then if pipeworks.toggles.pipe_mode == "pressure" then
abmregister.flowlogic(nodename) abmregister.flowlogic(nodename)
end end
end end
local regwarning = function(kind, nodename) local regwarning = function(kind, nodename)
local tail = "" local tail = ""
if not pipeworks.toggles.pressure_logic then tail = " but pressure logic not enabled" end if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail) --pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail)
end end