2013-07-13 22:39:25 -04:00
|
|
|
-- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
|
2012-07-12 17:52:35 -04:00
|
|
|
--
|
2013-07-13 22:39:25 -04:00
|
|
|
-- This mod supplies various steel pipes and plastic pneumatic tubes
|
|
|
|
-- and devices that they can connect to.
|
2012-07-12 17:52:35 -04:00
|
|
|
--
|
|
|
|
-- License: WTFPL
|
|
|
|
--
|
|
|
|
|
2013-10-29 14:08:23 -04:00
|
|
|
pipeworks = {}
|
|
|
|
|
2013-10-21 11:14:46 +02:00
|
|
|
local DEBUG = false
|
|
|
|
|
2013-10-29 14:08:23 -04:00
|
|
|
pipeworks.worldpath = minetest.get_worldpath()
|
|
|
|
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
2012-08-18 08:46:17 -04:00
|
|
|
|
2013-10-29 14:08:23 -04:00
|
|
|
dofile(pipeworks.modpath.."/default_settings.txt")
|
2012-08-18 08:46:17 -04:00
|
|
|
|
2013-12-17 20:36:21 -05:00
|
|
|
-- Read the external config file if it exists.
|
2013-12-17 20:28:54 -05:00
|
|
|
if io.open(pipeworks.worldpath.."/pipeworks_settings.txt","r") then
|
2013-10-29 14:08:23 -04:00
|
|
|
dofile(pipeworks.worldpath.."/pipeworks_settings.txt")
|
2013-12-17 20:36:21 -05:00
|
|
|
io.close()
|
2013-07-13 22:39:25 -04:00
|
|
|
end
|
2012-08-05 21:29:59 -04:00
|
|
|
|
2013-12-15 04:35:59 -05:00
|
|
|
-- Random variables
|
|
|
|
|
2013-12-15 02:53:10 -05:00
|
|
|
pipeworks.expect_infinite_stacks = true
|
2013-06-08 01:00:49 -04:00
|
|
|
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
2013-12-15 05:26:39 -05:00
|
|
|
pipeworks.expect_infinite_stacks = false
|
2013-06-08 01:00:49 -04:00
|
|
|
end
|
|
|
|
|
2013-12-15 02:53:10 -05: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 03:33:06 -05: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}}
|
|
|
|
|
2013-12-15 04:35:59 -05:00
|
|
|
pipeworks.liquid_texture = "default_water.png"
|
|
|
|
|
2013-12-15 02:53:10 -05:00
|
|
|
-- Helper functions
|
|
|
|
|
|
|
|
function pipeworks.fix_image_names(table, replacement)
|
|
|
|
local outtable={}
|
2012-08-18 08:46:17 -04:00
|
|
|
for i in ipairs(table) do
|
|
|
|
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
2012-08-05 21:29:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
return outtable
|
|
|
|
end
|
|
|
|
|
2013-12-15 04:35:59 -05:00
|
|
|
function pipeworks.add_node_box(t, b)
|
2015-01-15 06:25:41 -05:00
|
|
|
if not t or not b then return end
|
2012-08-18 08:46:17 -04:00
|
|
|
for i in ipairs(b)
|
|
|
|
do table.insert(t, b[i])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-15 02:53:10 -05:00
|
|
|
function pipeworks.node_is_owned(pos, placer)
|
2013-06-08 01:00:49 -04:00
|
|
|
local ownername = false
|
|
|
|
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
|
|
|
if HasOwner(pos, placer) then -- returns true if the node is owned
|
|
|
|
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
|
|
|
if type(getLastOwner) == "function" then -- ...is an old version
|
|
|
|
ownername = getLastOwner(pos)
|
|
|
|
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
|
|
|
ownername = GetNodeOwnerName(pos)
|
|
|
|
else
|
|
|
|
ownername = S("someone")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif type(isprotect)=="function" then -- glomie's protection mod
|
|
|
|
if not isprotect(5, pos, placer) then
|
|
|
|
ownername = S("someone")
|
|
|
|
end
|
|
|
|
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
|
|
|
|
if not protector.can_dig(5, pos, placer) then
|
|
|
|
ownername = S("someone")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if ownername ~= false then
|
|
|
|
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-15 02:53:10 -05:00
|
|
|
function pipeworks.replace_name(tbl,tr,name)
|
2013-07-13 22: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 02:53:10 -05:00
|
|
|
ntbl[key]=pipeworks.replace_name(i,tr,name)
|
2013-07-13 22:39:25 -04:00
|
|
|
else
|
|
|
|
ntbl[key]=i
|
2012-08-18 22:12:29 -04:00
|
|
|
end
|
2012-08-18 08:46:17 -04:00
|
|
|
end
|
2013-07-13 22:39:25 -04:00
|
|
|
return ntbl
|
2012-08-18 08:46:17 -04:00
|
|
|
end
|
|
|
|
|
2013-12-15 04:35:59 -05:00
|
|
|
-------------------------------------------
|
|
|
|
-- Load the various other parts of the mod
|
2013-06-22 17:51:57 -04:00
|
|
|
|
2014-08-14 16:22:03 +02:00
|
|
|
dofile(pipeworks.modpath.."/common.lua")
|
2013-12-15 04:35:59 -05:00
|
|
|
dofile(pipeworks.modpath.."/models.lua")
|
2013-11-25 23:55:52 -05:00
|
|
|
dofile(pipeworks.modpath.."/autoplace_pipes.lua")
|
|
|
|
dofile(pipeworks.modpath.."/autoplace_tubes.lua")
|
2014-08-14 16:22:03 +02:00
|
|
|
dofile(pipeworks.modpath.."/luaentity.lua")
|
2013-10-29 14:08:23 -04:00
|
|
|
dofile(pipeworks.modpath.."/item_transport.lua")
|
|
|
|
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
|
|
|
dofile(pipeworks.modpath.."/crafts.lua")
|
2015-01-29 22:52:13 +01:00
|
|
|
dofile(pipeworks.modpath.."/tube_registration.lua")
|
2015-01-29 22:24:14 +01: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 00:06:27 +01:00
|
|
|
dofile(pipeworks.modpath.."/decorative_tubes.lua")
|
2015-01-29 19:55:00 +01:00
|
|
|
dofile(pipeworks.modpath.."/filter-injector.lua")
|
2014-07-15 00:52:33 +01:00
|
|
|
dofile(pipeworks.modpath.."/trashcan.lua")
|
2014-07-22 15:33:16 +01:00
|
|
|
dofile(pipeworks.modpath.."/wielder.lua")
|
2013-07-13 22:39:25 -04:00
|
|
|
|
2013-12-15 04:43:13 -05: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
|
|
|
|
if pipeworks.enable_redefines then dofile(pipeworks.modpath.."/compat.lua") end
|
|
|
|
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
|
2014-07-11 09:15:37 -04:00
|
|
|
|
2013-07-13 22:39:25 -04:00
|
|
|
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
2013-01-31 18:49:47 -05:00
|
|
|
|
2012-08-05 21:29:59 -04:00
|
|
|
print("Pipeworks loaded!")
|
2013-12-15 02:53:10 -05:00
|
|
|
|