Update ancient pipeworks protection code
[minetest_hades/hades_revisited.git] / mods / pipeworks / init.lua
blob5d5c95cff49df5d785a3a8cc7e6d4cdc45e30fc0
1 -- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
2 --
3 -- This mod supplies various steel pipes and plastic pneumatic tubes
4 -- and devices that they can connect to.
5 --
6 -- License: WTFPL
7 --
9 pipeworks = {}
11 local DEBUG = false
13 pipeworks.worldpath = minetest.get_worldpath()
14 pipeworks.modpath = minetest.get_modpath("pipeworks")
16 dofile(pipeworks.modpath.."/default_settings.txt")
18 -- Read the external config file if it exists.
19 if io.open(pipeworks.worldpath.."/pipeworks_settings.txt","r") then
20 dofile(pipeworks.worldpath.."/pipeworks_settings.txt")
21 io.close()
22 end
24 -- Random variables
26 pipeworks.expect_infinite_stacks = true
27 if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
28 pipeworks.expect_infinite_stacks = false
29 end
31 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}}
33 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},
34 {x=0, y=1, z=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
35 {x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
36 {x=0, y=1, z=0}, {x=0, y=-1, z=0}}
38 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}}
40 pipeworks.liquid_texture = "default_water.png"
42 -- Helper functions
44 function pipeworks.fix_image_names(table, replacement)
45 local outtable={}
46 for i in ipairs(table) do
47 outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
48 end
50 return outtable
51 end
53 function pipeworks.add_node_box(t, b)
54 for i in ipairs(b)
55 do table.insert(t, b[i])
56 end
57 end
59 function pipeworks.node_is_owned(pos, placer)
60 local is_protected = minetest.is_protected(pos, placer:get_player_name())
61 if is_protected then
62 minetest.chat_send_player(placer:get_player_name(), S("Someone owns this spot."))
63 return true
64 else
65 return false
66 end
67 end
69 function pipeworks.replace_name(tbl,tr,name)
70 local ntbl={}
71 for key,i in pairs(tbl) do
72 if type(i)=="string" then
73 ntbl[key]=string.gsub(i,tr,name)
74 elseif type(i)=="table" then
75 ntbl[key]=pipeworks.replace_name(i,tr,name)
76 else
77 ntbl[key]=i
78 end
79 end
80 return ntbl
81 end
83 -------------------------------------------
84 -- Load the various other parts of the mod
86 dofile(pipeworks.modpath.."/models.lua")
87 dofile(pipeworks.modpath.."/autoplace_pipes.lua")
88 dofile(pipeworks.modpath.."/autoplace_tubes.lua")
89 dofile(pipeworks.modpath.."/item_transport.lua")
90 dofile(pipeworks.modpath.."/flowing_logic.lua")
91 dofile(pipeworks.modpath.."/crafts.lua")
92 dofile(pipeworks.modpath.."/tubes.lua")
94 if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
95 if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
96 if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
97 if pipeworks.enable_redefines then dofile(pipeworks.modpath.."/compat.lua") end
98 if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
99 if pipeworks.enable_deployer then dofile(pipeworks.modpath.."/deployer.lua") end
100 if pipeworks.enable_node_breaker then dofile(pipeworks.modpath.."/node_breaker.lua") end
102 minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
104 minetest.log("action", "Pipeworks loaded!")