2013-07-14 06:39:25 +04:00
|
|
|
-- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
|
2012-07-13 01:52:35 +04:00
|
|
|
--
|
2013-07-14 06:39:25 +04:00
|
|
|
-- This mod supplies various steel pipes and plastic pneumatic tubes
|
|
|
|
-- and devices that they can connect to.
|
2012-07-13 01:52:35 +04:00
|
|
|
--
|
|
|
|
|
2013-10-29 22:08:23 +04:00
|
|
|
pipeworks = {}
|
2021-04-02 22:48:28 +03:00
|
|
|
pipeworks.ui_cat_tube_list = {}
|
2013-10-29 22:08:23 +04:00
|
|
|
|
|
|
|
pipeworks.worldpath = minetest.get_worldpath()
|
|
|
|
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
2020-02-18 20:34:52 +03:00
|
|
|
local S = minetest.get_translator("pipeworks")
|
2012-08-18 16:46:17 +04:00
|
|
|
|
2017-04-14 04:13:30 +03:00
|
|
|
dofile(pipeworks.modpath.."/default_settings.lua")
|
2013-12-18 05:36:21 +04:00
|
|
|
-- Read the external config file if it exists.
|
2016-05-28 03:37:56 +03:00
|
|
|
local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt"
|
|
|
|
local worldsettingsfile = io.open(worldsettingspath, "r")
|
2016-05-23 20:52:26 +03:00
|
|
|
if worldsettingsfile then
|
|
|
|
worldsettingsfile:close()
|
|
|
|
dofile(worldsettingspath)
|
2013-07-14 06:39:25 +04:00
|
|
|
end
|
2017-10-21 00:46:51 +03:00
|
|
|
if pipeworks.toggles.pipe_mode == "pressure" then
|
2017-10-20 23:34:08 +03:00
|
|
|
minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
|
2017-09-27 19:37:46 +03:00
|
|
|
end
|
2012-08-06 05:29:59 +04:00
|
|
|
|
2013-12-15 13:35:59 +04:00
|
|
|
-- Random variables
|
|
|
|
|
2013-12-15 11:53:10 +04:00
|
|
|
pipeworks.expect_infinite_stacks = true
|
2017-05-18 12:33:56 +03:00
|
|
|
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
|
2013-12-15 14:26:39 +04:00
|
|
|
pipeworks.expect_infinite_stacks = false
|
2013-06-08 09:00:49 +04:00
|
|
|
end
|
|
|
|
|
2013-12-15 11:53:10 +04:00
|
|
|
pipeworks.meseadjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
|
|
|
|
|
2013-12-21 12:33:06 +04:00
|
|
|
pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y=0, z=0},
|
|
|
|
{x=0, y=1, z=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
|
|
|
|
{x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
|
|
|
|
{x=0, y=1, z=0}, {x=0, y=-1, z=0}}
|
|
|
|
|
|
|
|
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
|
2017-09-26 06:19:35 +03:00
|
|
|
pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
|
2013-12-21 12:33:06 +04:00
|
|
|
|
2013-12-15 13:35:59 +04:00
|
|
|
pipeworks.liquid_texture = "default_water.png"
|
|
|
|
|
2017-04-12 02:16:21 +03:00
|
|
|
pipeworks.button_off = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
|
|
|
|
pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
|
|
|
pipeworks.button_base = "image_button[0,4.3;1,0.6"
|
2020-02-18 20:34:52 +03:00
|
|
|
pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
|
2017-04-12 01:52:39 +03:00
|
|
|
|
2013-12-15 11:53:10 +04:00
|
|
|
-- Helper functions
|
|
|
|
|
|
|
|
function pipeworks.fix_image_names(table, replacement)
|
|
|
|
local outtable={}
|
2012-08-18 16:46:17 +04:00
|
|
|
for i in ipairs(table) do
|
|
|
|
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
2012-08-06 05:29:59 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
return outtable
|
|
|
|
end
|
|
|
|
|
2013-12-15 13:35:59 +04:00
|
|
|
function pipeworks.add_node_box(t, b)
|
2015-01-15 14:25:41 +03:00
|
|
|
if not t or not b then return end
|
2012-08-18 16:46:17 +04:00
|
|
|
for i in ipairs(b)
|
|
|
|
do table.insert(t, b[i])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-05 13:14:30 +03:00
|
|
|
function pipeworks.may_configure(pos, player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local owner = meta:get_string("owner")
|
|
|
|
|
2020-09-24 14:12:32 +03:00
|
|
|
if owner ~= "" and owner == name then -- wielders and filters
|
|
|
|
return true
|
2015-03-05 13:14:30 +03:00
|
|
|
end
|
|
|
|
return not minetest.is_protected(pos, name)
|
|
|
|
end
|
|
|
|
|
2013-12-15 11:53:10 +04:00
|
|
|
function pipeworks.replace_name(tbl,tr,name)
|
2013-07-14 06:39:25 +04:00
|
|
|
local ntbl={}
|
|
|
|
for key,i in pairs(tbl) do
|
|
|
|
if type(i)=="string" then
|
|
|
|
ntbl[key]=string.gsub(i,tr,name)
|
|
|
|
elseif type(i)=="table" then
|
2013-12-15 11:53:10 +04:00
|
|
|
ntbl[key]=pipeworks.replace_name(i,tr,name)
|
2013-07-14 06:39:25 +04:00
|
|
|
else
|
|
|
|
ntbl[key]=i
|
2012-08-19 06:12:29 +04:00
|
|
|
end
|
2012-08-18 16:46:17 +04:00
|
|
|
end
|
2013-07-14 06:39:25 +04:00
|
|
|
return ntbl
|
2012-08-18 16:46:17 +04:00
|
|
|
end
|
|
|
|
|
2017-10-01 18:17:35 +03:00
|
|
|
pipeworks.logger = function(msg)
|
|
|
|
print("[pipeworks] "..msg)
|
|
|
|
end
|
|
|
|
|
2013-12-15 13:35:59 +04:00
|
|
|
-------------------------------------------
|
|
|
|
-- Load the various other parts of the mod
|
2013-06-23 01:51:57 +04:00
|
|
|
|
2017-10-03 22:53:49 +03:00
|
|
|
-- early auto-detection for finite water mode if not explicitly disabled
|
|
|
|
if pipeworks.toggles.finite_water == nil then
|
|
|
|
dofile(pipeworks.modpath.."/autodetect-finite-water.lua")
|
|
|
|
end
|
|
|
|
|
2019-09-23 19:21:54 +03:00
|
|
|
if minetest.get_modpath("signs_lib") then
|
|
|
|
dofile(pipeworks.modpath.."/signs_compat.lua")
|
|
|
|
end
|
|
|
|
|
2014-08-14 18:22:03 +04:00
|
|
|
dofile(pipeworks.modpath.."/common.lua")
|
2013-12-15 13:35:59 +04:00
|
|
|
dofile(pipeworks.modpath.."/models.lua")
|
2013-11-26 08:55:52 +04:00
|
|
|
dofile(pipeworks.modpath.."/autoplace_pipes.lua")
|
|
|
|
dofile(pipeworks.modpath.."/autoplace_tubes.lua")
|
2014-08-14 18:22:03 +04:00
|
|
|
dofile(pipeworks.modpath.."/luaentity.lua")
|
2013-10-29 22:08:23 +04:00
|
|
|
dofile(pipeworks.modpath.."/item_transport.lua")
|
|
|
|
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
|
|
|
dofile(pipeworks.modpath.."/crafts.lua")
|
2015-01-30 00:52:13 +03:00
|
|
|
dofile(pipeworks.modpath.."/tube_registration.lua")
|
2015-01-30 00:24:14 +03:00
|
|
|
dofile(pipeworks.modpath.."/routing_tubes.lua")
|
|
|
|
dofile(pipeworks.modpath.."/sorting_tubes.lua")
|
|
|
|
dofile(pipeworks.modpath.."/vacuum_tubes.lua")
|
|
|
|
dofile(pipeworks.modpath.."/signal_tubes.lua")
|
2015-01-31 02:06:27 +03:00
|
|
|
dofile(pipeworks.modpath.."/decorative_tubes.lua")
|
2015-01-29 21:55:00 +03:00
|
|
|
dofile(pipeworks.modpath.."/filter-injector.lua")
|
2014-07-15 03:52:33 +04:00
|
|
|
dofile(pipeworks.modpath.."/trashcan.lua")
|
2014-07-22 18:33:16 +04:00
|
|
|
dofile(pipeworks.modpath.."/wielder.lua")
|
2013-07-14 06:39:25 +04:00
|
|
|
|
2017-10-17 16:20:55 +03:00
|
|
|
local logicdir = "/pressure_logic/"
|
2017-10-01 01:55:16 +03:00
|
|
|
|
2017-10-01 20:23:58 +03:00
|
|
|
-- note that even with these files the new flow logic is not yet default.
|
|
|
|
-- registration will take place but no actual ABMs/node logic will be installed,
|
2017-10-03 22:38:56 +03:00
|
|
|
-- unless the toggle flag is specifically enabled in the per-world settings flag.
|
2017-10-01 17:18:00 +03:00
|
|
|
dofile(pipeworks.modpath..logicdir.."flowable_node_registry.lua")
|
2017-10-01 01:55:16 +03:00
|
|
|
dofile(pipeworks.modpath..logicdir.."abms.lua")
|
|
|
|
dofile(pipeworks.modpath..logicdir.."abm_register.lua")
|
2017-10-01 17:18:00 +03:00
|
|
|
dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua")
|
2017-09-30 22:16:00 +03:00
|
|
|
|
2013-12-15 13:43:13 +04:00
|
|
|
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
|
|
|
|
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
|
|
|
|
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
|
2017-04-11 06:13:44 +03:00
|
|
|
if pipeworks.enable_redefines then
|
|
|
|
dofile(pipeworks.modpath.."/compat-chests.lua")
|
|
|
|
dofile(pipeworks.modpath.."/compat-furnaces.lua")
|
|
|
|
end
|
2013-12-15 13:43:13 +04:00
|
|
|
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
|
2018-12-08 23:01:47 +03:00
|
|
|
if pipeworks.enable_lua_tube and
|
|
|
|
(minetest.get_modpath("mesecons") or minetest.get_modpath("digilines")) then
|
|
|
|
dofile(pipeworks.modpath.."/lua_tube.lua")
|
|
|
|
end
|
2014-07-11 17:15:37 +04:00
|
|
|
|
2013-07-14 06:39:25 +04:00
|
|
|
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
2013-02-01 03:49:47 +04:00
|
|
|
|
2021-04-02 22:48:28 +03:00
|
|
|
-- Unified Inventory categories integration
|
|
|
|
|
2021-05-13 20:57:58 +03:00
|
|
|
if minetest.global_exists("unified_inventory") and unified_inventory.registered_categories then
|
2021-04-02 22:48:28 +03:00
|
|
|
if not unified_inventory.registered_categories["automation"] then
|
|
|
|
unified_inventory.register_category("automation", {
|
|
|
|
symbol = "pipeworks:lua_tube000000",
|
|
|
|
label = "Automation components"
|
|
|
|
})
|
|
|
|
end
|
|
|
|
unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list)
|
|
|
|
end
|
|
|
|
|
2016-02-21 11:15:43 +03:00
|
|
|
minetest.log("info", "Pipeworks loaded!")
|