forked from mtcontrib/pipeworks
added ability to disable most components via config file in world folder
moved pipes out of init.lua and into a separate file. some minor formatting changes
This commit is contained in:
parent
1a9a940e84
commit
c0af957167
17
default_settings.txt
Normal file
17
default_settings.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-- Various settings
|
||||||
|
|
||||||
|
enable_pipes = true
|
||||||
|
enable_autocrafter = true
|
||||||
|
enable_deployer = true
|
||||||
|
enable_node_breaker = true
|
||||||
|
enable_teleport_tube = true
|
||||||
|
enable_pipe_devices = true
|
||||||
|
enable_redefines = true
|
||||||
|
enable_mese_tube = true
|
||||||
|
enable_detector_tube = true
|
||||||
|
enable_conductor_tube = true
|
||||||
|
enable_accelerator_tube = true
|
||||||
|
enable_crossing_tube = true
|
||||||
|
enable_sand_tube = true
|
||||||
|
enable_mese_sand_tube = true
|
||||||
|
|
48
devices.lua
48
devices.lua
@ -89,8 +89,8 @@ for s in ipairs(states) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pumpboxes = {}
|
local pumpboxes = {}
|
||||||
pipe_addbox(pumpboxes, pipe_pumpbody)
|
pipeworks_add_pipebox(pumpboxes, pipe_pumpbody)
|
||||||
pipe_addbox(pumpboxes, pipe_topstub)
|
pipeworks_add_pipebox(pumpboxes, pipe_topstub)
|
||||||
|
|
||||||
minetest.register_node("pipeworks:pump_"..states[s], {
|
minetest.register_node("pipeworks:pump_"..states[s], {
|
||||||
description = "Pump/Intake Module",
|
description = "Pump/Intake Module",
|
||||||
@ -134,14 +134,14 @@ for s in ipairs(states) do
|
|||||||
})
|
})
|
||||||
|
|
||||||
local valveboxes = {}
|
local valveboxes = {}
|
||||||
pipe_addbox(valveboxes, pipe_leftstub)
|
pipeworks_add_pipebox(valveboxes, pipe_leftstub)
|
||||||
pipe_addbox(valveboxes, pipe_valvebody)
|
pipeworks_add_pipebox(valveboxes, pipe_valvebody)
|
||||||
if states[s] == "off" then
|
if states[s] == "off" then
|
||||||
pipe_addbox(valveboxes, pipe_valvehandle_off)
|
pipeworks_add_pipebox(valveboxes, pipe_valvehandle_off)
|
||||||
else
|
else
|
||||||
pipe_addbox(valveboxes, pipe_valvehandle_on)
|
pipeworks_add_pipebox(valveboxes, pipe_valvehandle_on)
|
||||||
end
|
end
|
||||||
pipe_addbox(valveboxes, pipe_rightstub)
|
pipeworks_add_pipebox(valveboxes, pipe_rightstub)
|
||||||
local tilex = "pipeworks_valvebody_ends.png"
|
local tilex = "pipeworks_valvebody_ends.png"
|
||||||
local tilez = "pipeworks_valvebody_sides.png"
|
local tilez = "pipeworks_valvebody_sides.png"
|
||||||
|
|
||||||
@ -189,10 +189,10 @@ for s in ipairs(states) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
local valveboxes = {}
|
local valveboxes = {}
|
||||||
pipe_addbox(valveboxes, pipe_leftstub)
|
pipeworks_add_pipebox(valveboxes, pipe_leftstub)
|
||||||
pipe_addbox(valveboxes, pipe_valvebody)
|
pipeworks_add_pipebox(valveboxes, pipe_valvebody)
|
||||||
pipe_addbox(valveboxes, pipe_rightstub)
|
pipeworks_add_pipebox(valveboxes, pipe_rightstub)
|
||||||
pipe_addbox(valveboxes, pipe_valvehandle_on)
|
pipeworks_add_pipebox(valveboxes, pipe_valvehandle_on)
|
||||||
|
|
||||||
minetest.register_node("pipeworks:valve_on_loaded", {
|
minetest.register_node("pipeworks:valve_on_loaded", {
|
||||||
description = "Valve",
|
description = "Valve",
|
||||||
@ -264,15 +264,15 @@ minetest.register_node("pipeworks:grating", {
|
|||||||
-- outlet spigot
|
-- outlet spigot
|
||||||
|
|
||||||
local spigotboxes = {}
|
local spigotboxes = {}
|
||||||
pipe_addbox(spigotboxes, pipe_backstub)
|
pipeworks_add_pipebox(spigotboxes, pipe_backstub)
|
||||||
pipe_addbox(spigotboxes, spigot_bottomstub)
|
pipeworks_add_pipebox(spigotboxes, spigot_bottomstub)
|
||||||
pipe_addbox(spigotboxes, pipe_bendsphere)
|
pipeworks_add_pipebox(spigotboxes, pipe_bendsphere)
|
||||||
|
|
||||||
local spigotboxes_pouring = {}
|
local spigotboxes_pouring = {}
|
||||||
pipe_addbox(spigotboxes_pouring, spigot_stream)
|
pipeworks_add_pipebox(spigotboxes_pouring, spigot_stream)
|
||||||
pipe_addbox(spigotboxes_pouring, pipe_backstub)
|
pipeworks_add_pipebox(spigotboxes_pouring, pipe_backstub)
|
||||||
pipe_addbox(spigotboxes_pouring, spigot_bottomstub)
|
pipeworks_add_pipebox(spigotboxes_pouring, spigot_bottomstub)
|
||||||
pipe_addbox(spigotboxes_pouring, pipe_bendsphere)
|
pipeworks_add_pipebox(spigotboxes_pouring, pipe_bendsphere)
|
||||||
|
|
||||||
minetest.register_node("pipeworks:spigot", {
|
minetest.register_node("pipeworks:spigot", {
|
||||||
description = "Spigot outlet",
|
description = "Spigot outlet",
|
||||||
@ -373,9 +373,9 @@ minetest.register_node("pipeworks:spigot_pouring", {
|
|||||||
-- wall, for use in places where walls should look like they're airtight)
|
-- wall, for use in places where walls should look like they're airtight)
|
||||||
|
|
||||||
local airtightboxes = {}
|
local airtightboxes = {}
|
||||||
pipe_addbox(airtightboxes, pipe_frontstub)
|
pipeworks_add_pipebox(airtightboxes, pipe_frontstub)
|
||||||
pipe_addbox(airtightboxes, pipe_backstub)
|
pipeworks_add_pipebox(airtightboxes, pipe_backstub)
|
||||||
pipe_addbox(airtightboxes, entry_panel)
|
pipeworks_add_pipebox(airtightboxes, entry_panel)
|
||||||
|
|
||||||
minetest.register_node("pipeworks:entry_panel_empty", {
|
minetest.register_node("pipeworks:entry_panel_empty", {
|
||||||
description = "Airtight Pipe entry/exit",
|
description = "Airtight Pipe entry/exit",
|
||||||
@ -500,9 +500,9 @@ minetest.register_node("pipeworks:entry_panel_loaded", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
local sensorboxes = {}
|
local sensorboxes = {}
|
||||||
pipe_addbox(sensorboxes, pipe_leftstub)
|
pipeworks_add_pipebox(sensorboxes, pipe_leftstub)
|
||||||
pipe_addbox(sensorboxes, pipe_sensorbody)
|
pipeworks_add_pipebox(sensorboxes, pipe_sensorbody)
|
||||||
pipe_addbox(sensorboxes, pipe_rightstub)
|
pipeworks_add_pipebox(sensorboxes, pipe_rightstub)
|
||||||
|
|
||||||
minetest.register_node("pipeworks:flow_sensor_empty", {
|
minetest.register_node("pipeworks:flow_sensor_empty", {
|
||||||
description = "Flow Sensor",
|
description = "Flow Sensor",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
-- This file provides the actual flow and pathfinding logic that makes water
|
-- This file provides the actual flow and pathfinding logic that makes water
|
||||||
-- move through the pipes.
|
-- move through the pipes.
|
||||||
--
|
--
|
||||||
-- Contributed by mauvebic, 2013-01-03, with tweaks by Vanessa Ezekowitz
|
-- Contributed by mauvebic, 2013-01-03, rewritten a bit by Vanessa Ezekowitz
|
||||||
--
|
--
|
||||||
|
|
||||||
local finitewater = minetest.setting_getbool("liquid_finite")
|
local finitewater = minetest.setting_getbool("liquid_finite")
|
||||||
|
|
||||||
local check4liquids = function(pos)
|
pipeworks_check_for_liquids = function(pos)
|
||||||
local coords = {
|
local coords = {
|
||||||
{x=pos.x,y=pos.y-1,z=pos.z},
|
{x=pos.x,y=pos.y-1,z=pos.z},
|
||||||
{x=pos.x,y=pos.y+1,z=pos.z},
|
{x=pos.x,y=pos.y+1,z=pos.z},
|
||||||
@ -24,7 +24,7 @@ local check4liquids = function(pos)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local check4inflows = function(pos,node)
|
pipeworks_check_for_inflows = function(pos,node)
|
||||||
local coords = {
|
local coords = {
|
||||||
{x=pos.x,y=pos.y-1,z=pos.z},
|
{x=pos.x,y=pos.y-1,z=pos.z},
|
||||||
{x=pos.x,y=pos.y+1,z=pos.z},
|
{x=pos.x,y=pos.y+1,z=pos.z},
|
||||||
@ -37,7 +37,7 @@ local check4inflows = function(pos,node)
|
|||||||
for i =1,6 do
|
for i =1,6 do
|
||||||
if newnode then break end
|
if newnode then break end
|
||||||
local name = minetest.get_node(coords[i]).name
|
local name = minetest.get_node(coords[i]).name
|
||||||
if (name == "pipeworks:pump_on" and check4liquids(coords[i])) or string.find(name,"_loaded") then
|
if (name == "pipeworks:pump_on" and pipeworks_check_for_liquids(coords[i])) or string.find(name,"_loaded") then
|
||||||
if string.find(name,"_loaded") then
|
if string.find(name,"_loaded") then
|
||||||
local source = minetest.get_meta(coords[i]):get_string("source")
|
local source = minetest.get_meta(coords[i]):get_string("source")
|
||||||
if source == minetest.pos_to_string(pos) then break end
|
if source == minetest.pos_to_string(pos) then break end
|
||||||
@ -52,12 +52,12 @@ local check4inflows = function(pos,node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local checksources = function(pos,node)
|
pipeworks_check_sources = function(pos,node)
|
||||||
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
|
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
|
||||||
if not sourcepos then return end
|
if not sourcepos then return end
|
||||||
local source = minetest.get_node(sourcepos).name
|
local source = minetest.get_node(sourcepos).name
|
||||||
local newnode = false
|
local newnode = false
|
||||||
if not ((source == "pipeworks:pump_on" and check4liquids(sourcepos)) or string.find(source,"_loaded") or source == "ignore" ) then
|
if not ((source == "pipeworks:pump_on" and pipeworks_check_for_liquids(sourcepos)) or string.find(source,"_loaded") or source == "ignore" ) then
|
||||||
newnode = string.gsub(node.name,"loaded","empty")
|
newnode = string.gsub(node.name,"loaded","empty")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ local checksources = function(pos,node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local spigot_check = function(pos, node)
|
pipeworks_spigot_check = function(pos, node)
|
||||||
local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
|
local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
|
||||||
if belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source" then
|
if belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source" then
|
||||||
local spigotname = minetest.get_node(pos).name
|
local spigotname = minetest.get_node(pos).name
|
||||||
@ -96,34 +96,3 @@ local spigot_check = function(pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_empty")
|
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
|
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
|
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:flow_sensor_empty")
|
|
||||||
|
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
|
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
|
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = pipes_empty_nodenames,
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider) check4inflows(pos,node) end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = pipes_full_nodenames,
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider) checksources(pos,node) end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
spigot_check(pos,node)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
347
init.lua
347
init.lua
@ -1,115 +1,35 @@
|
|||||||
-- Pipeworks mod by Vanessa Ezekowitz - 2012-08-05
|
-- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
|
||||||
--
|
--
|
||||||
-- Entirely my own code. This mod supplies various shapes of pipes
|
-- This mod supplies various steel pipes and plastic pneumatic tubes
|
||||||
-- and devices that they can connect to such as pumps, valves, etc.
|
-- and devices that they can connect to.
|
||||||
-- All pipes autoconnect as you lay them out, and devices will auto-
|
|
||||||
-- connect to them.
|
|
||||||
--
|
--
|
||||||
-- License: WTFPL
|
-- License: WTFPL
|
||||||
--
|
--
|
||||||
|
|
||||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
-- Copy and/or read the config file
|
||||||
local DEBUG = false
|
|
||||||
local CYCLIC = true
|
|
||||||
|
|
||||||
pipeworks_liquid_texture = "default_water.png"
|
local worldpath = minetest.get_worldpath()
|
||||||
|
local modpath = minetest.get_modpath("pipeworks")
|
||||||
|
|
||||||
pipe_leftstub = {
|
if io.open(worldpath.."/pipeworks_settings.txt","r") == nil then
|
||||||
{ -32/64, -2/64, -6/64, 1/64, 2/64, 6/64 }, -- pipe segment against -X face
|
|
||||||
{ -32/64, -4/64, -5/64, 1/64, 4/64, 5/64 },
|
|
||||||
{ -32/64, -5/64, -4/64, 1/64, 5/64, 4/64 },
|
|
||||||
{ -32/64, -6/64, -2/64, 1/64, 6/64, 2/64 },
|
|
||||||
|
|
||||||
{ -32/64, -3/64, -8/64, -30/64, 3/64, 8/64 }, -- (the flange for it)
|
dofile(modpath.."/default_settings.txt")
|
||||||
{ -32/64, -5/64, -7/64, -30/64, 5/64, 7/64 },
|
|
||||||
{ -32/64, -6/64, -6/64, -30/64, 6/64, 6/64 },
|
|
||||||
{ -32/64, -7/64, -5/64, -30/64, 7/64, 5/64 },
|
|
||||||
{ -32/64, -8/64, -3/64, -30/64, 8/64, 3/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_rightstub = {
|
io.input(modpath.."/default_settings.txt")
|
||||||
{ -1/64, -2/64, -6/64, 32/64, 2/64, 6/64 }, -- pipe segment against +X face
|
io.output(worldpath.."/pipeworks_settings.txt")
|
||||||
{ -1/64, -4/64, -5/64, 32/64, 4/64, 5/64 },
|
|
||||||
{ -1/64, -5/64, -4/64, 32/64, 5/64, 4/64 },
|
|
||||||
{ -1/64, -6/64, -2/64, 32/64, 6/64, 2/64 },
|
|
||||||
|
|
||||||
{ 30/64, -3/64, -8/64, 32/64, 3/64, 8/64 }, -- (the flange for it)
|
local size = 2^13 -- good buffer size (8K)
|
||||||
{ 30/64, -5/64, -7/64, 32/64, 5/64, 7/64 },
|
while true do
|
||||||
{ 30/64, -6/64, -6/64, 32/64, 6/64, 6/64 },
|
local block = io.read(size)
|
||||||
{ 30/64, -7/64, -5/64, 32/64, 7/64, 5/64 },
|
if not block then break end
|
||||||
{ 30/64, -8/64, -3/64, 32/64, 8/64, 3/64 }
|
io.write(block)
|
||||||
}
|
end
|
||||||
|
|
||||||
pipe_bottomstub = {
|
else
|
||||||
{ -2/64, -32/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
|
dofile(worldpath.."/pipeworks_settings.txt")
|
||||||
{ -4/64, -32/64, -5/64, 4/64, 1/64, 5/64 },
|
end
|
||||||
{ -5/64, -32/64, -4/64, 5/64, 1/64, 4/64 },
|
|
||||||
{ -6/64, -32/64, -2/64, 6/64, 1/64, 2/64 },
|
|
||||||
|
|
||||||
{ -3/64, -32/64, -8/64, 3/64, -30/64, 8/64 }, -- (the flange for it)
|
-- Helper functions
|
||||||
{ -5/64, -32/64, -7/64, 5/64, -30/64, 7/64 },
|
|
||||||
{ -6/64, -32/64, -6/64, 6/64, -30/64, 6/64 },
|
|
||||||
{ -7/64, -32/64, -5/64, 7/64, -30/64, 5/64 },
|
|
||||||
{ -8/64, -32/64, -3/64, 8/64, -30/64, 3/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pipe_topstub = {
|
|
||||||
{ -2/64, -1/64, -6/64, 2/64, 32/64, 6/64 }, -- pipe segment against +Y face
|
|
||||||
{ -4/64, -1/64, -5/64, 4/64, 32/64, 5/64 },
|
|
||||||
{ -5/64, -1/64, -4/64, 5/64, 32/64, 4/64 },
|
|
||||||
{ -6/64, -1/64, -2/64, 6/64, 32/64, 2/64 },
|
|
||||||
|
|
||||||
{ -3/64, 30/64, -8/64, 3/64, 32/64, 8/64 }, -- (the flange for it)
|
|
||||||
{ -5/64, 30/64, -7/64, 5/64, 32/64, 7/64 },
|
|
||||||
{ -6/64, 30/64, -6/64, 6/64, 32/64, 6/64 },
|
|
||||||
{ -7/64, 30/64, -5/64, 7/64, 32/64, 5/64 },
|
|
||||||
{ -8/64, 30/64, -3/64, 8/64, 32/64, 3/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_frontstub = {
|
|
||||||
{ -6/64, -2/64, -32/64, 6/64, 2/64, 1/64 }, -- pipe segment against -Z face
|
|
||||||
{ -5/64, -4/64, -32/64, 5/64, 4/64, 1/64 },
|
|
||||||
{ -4/64, -5/64, -32/64, 4/64, 5/64, 1/64 },
|
|
||||||
{ -2/64, -6/64, -32/64, 2/64, 6/64, 1/64 },
|
|
||||||
|
|
||||||
{ -8/64, -3/64, -32/64, 8/64, 3/64, -30/64 }, -- (the flange for it)
|
|
||||||
{ -7/64, -5/64, -32/64, 7/64, 5/64, -30/64 },
|
|
||||||
{ -6/64, -6/64, -32/64, 6/64, 6/64, -30/64 },
|
|
||||||
{ -5/64, -7/64, -32/64, 5/64, 7/64, -30/64 },
|
|
||||||
{ -3/64, -8/64, -32/64, 3/64, 8/64, -30/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_backstub = {
|
|
||||||
{ -6/64, -2/64, -1/64, 6/64, 2/64, 32/64 }, -- pipe segment against -Z face
|
|
||||||
{ -5/64, -4/64, -1/64, 5/64, 4/64, 32/64 },
|
|
||||||
{ -4/64, -5/64, -1/64, 4/64, 5/64, 32/64 },
|
|
||||||
{ -2/64, -6/64, -1/64, 2/64, 6/64, 32/64 },
|
|
||||||
|
|
||||||
{ -8/64, -3/64, 30/64, 8/64, 3/64, 32/64 }, -- (the flange for it)
|
|
||||||
{ -7/64, -5/64, 30/64, 7/64, 5/64, 32/64 },
|
|
||||||
{ -6/64, -6/64, 30/64, 6/64, 6/64, 32/64 },
|
|
||||||
{ -5/64, -7/64, 30/64, 5/64, 7/64, 32/64 },
|
|
||||||
{ -3/64, -8/64, 30/64, 3/64, 8/64, 32/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_selectboxes = {
|
|
||||||
{ -32/64, -8/64, -8/64, 8/64, 8/64, 8/64 },
|
|
||||||
{ -8/64 , -8/64, -8/64, 32/64, 8/64, 8/64 },
|
|
||||||
{ -8/64 , -32/64, -8/64, 8/64, 8/64, 8/64 },
|
|
||||||
{ -8/64 , -8/64, -8/64, 8/64, 32/64, 8/64 },
|
|
||||||
{ -8/64 , -8/64, -32/64, 8/64, 8/64, 8/64 },
|
|
||||||
{ -8/64 , -8/64, -8/64, 8/64, 8/64, 32/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_bendsphere = {
|
|
||||||
{ -4/64, -4/64, -4/64, 4/64, 4/64, 4/64 },
|
|
||||||
{ -5/64, -3/64, -3/64, 5/64, 3/64, 3/64 },
|
|
||||||
{ -3/64, -5/64, -3/64, 3/64, 5/64, 3/64 },
|
|
||||||
{ -3/64, -3/64, -5/64, 3/64, 3/64, 5/64 }
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Functions
|
|
||||||
|
|
||||||
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
||||||
pipeworks_expect_infinite_stacks = false
|
pipeworks_expect_infinite_stacks = false
|
||||||
@ -117,13 +37,7 @@ else
|
|||||||
pipeworks_expect_infinite_stacks = true
|
pipeworks_expect_infinite_stacks = true
|
||||||
end
|
end
|
||||||
|
|
||||||
dbg = function(s)
|
function pipeworks_fix_image_names(table, replacement)
|
||||||
if DEBUG then
|
|
||||||
print('[PIPEWORKS] ' .. s)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function pipes_fix_image_names(table, replacement)
|
|
||||||
outtable={}
|
outtable={}
|
||||||
for i in ipairs(table) do
|
for i in ipairs(table) do
|
||||||
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
||||||
@ -132,7 +46,7 @@ function pipes_fix_image_names(table, replacement)
|
|||||||
return outtable
|
return outtable
|
||||||
end
|
end
|
||||||
|
|
||||||
function pipe_addbox(t, b)
|
function pipeworks_add_pipebox(t, b)
|
||||||
for i in ipairs(b)
|
for i in ipairs(b)
|
||||||
do table.insert(t, b[i])
|
do table.insert(t, b[i])
|
||||||
end
|
end
|
||||||
@ -171,200 +85,39 @@ function pipeworks_node_is_owned(pos, placer)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- now define the nodes!
|
function pipeworks_replace_name(tbl,tr,name)
|
||||||
|
local ntbl={}
|
||||||
pipes_empty_nodenames = {}
|
for key,i in pairs(tbl) do
|
||||||
pipes_full_nodenames = {}
|
if type(i)=="string" then
|
||||||
|
ntbl[key]=string.gsub(i,tr,name)
|
||||||
for xm = 0, 1 do
|
elseif type(i)=="table" then
|
||||||
for xp = 0, 1 do
|
ntbl[key]=pipeworks_replace_name(i,tr,name)
|
||||||
for ym = 0, 1 do
|
else
|
||||||
for yp = 0, 1 do
|
ntbl[key]=i
|
||||||
for zm = 0, 1 do
|
|
||||||
for zp = 0, 1 do
|
|
||||||
local outboxes = {}
|
|
||||||
local outsel = {}
|
|
||||||
local outimgs = {}
|
|
||||||
|
|
||||||
if yp==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_topstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[4])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if ym==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_bottomstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[3])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if xp==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_rightstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[2])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if xm==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_leftstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[1])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if zp==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_backstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[6])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if zm==1 then
|
|
||||||
pipe_addbox(outboxes, pipe_frontstub)
|
|
||||||
table.insert(outsel, pipe_selectboxes[5])
|
|
||||||
table.insert(outimgs, "pipeworks_pipe_end.png")
|
|
||||||
else
|
|
||||||
table.insert(outimgs, "pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
|
|
||||||
local jx = xp+xm
|
|
||||||
local jy = yp+ym
|
|
||||||
local jz = zp+zm
|
|
||||||
|
|
||||||
if (jx+jy+jz) == 1 then
|
|
||||||
if xm == 1 then
|
|
||||||
table.remove(outimgs, 3)
|
|
||||||
table.insert(outimgs, 3, "^pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if xp == 1 then
|
|
||||||
table.remove(outimgs, 4)
|
|
||||||
table.insert(outimgs, 4, "^pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if ym == 1 then
|
|
||||||
table.remove(outimgs, 1)
|
|
||||||
table.insert(outimgs, 1, "^pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if xp == 1 then
|
|
||||||
table.remove(outimgs, 2)
|
|
||||||
table.insert(outimgs, 2, "^pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if zm == 1 then
|
|
||||||
table.remove(outimgs, 5)
|
|
||||||
table.insert(outimgs, 5, "^pipeworks_plain.png")
|
|
||||||
end
|
|
||||||
if zp == 1 then
|
|
||||||
table.remove(outimgs, 6)
|
|
||||||
table.insert(outimgs, 6, "^pipeworks_plain.png")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return ntbl
|
||||||
if jx+jy+jz >= 2 then
|
|
||||||
pipe_addbox(outboxes, pipe_bendsphere)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (jx==2 and jy~=2 and jz~=2) then
|
|
||||||
table.remove(outimgs, 5)
|
|
||||||
table.remove(outimgs, 5)
|
|
||||||
table.insert(outimgs, 5, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
|
||||||
table.insert(outimgs, 5, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
|
||||||
end
|
|
||||||
|
|
||||||
if (jx~=2 and jy~=2 and jz==2) or (jx~=2 and jy==2 and jz~=2) then
|
|
||||||
table.remove(outimgs, 3)
|
|
||||||
table.remove(outimgs, 3)
|
|
||||||
table.insert(outimgs, 3, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
|
||||||
table.insert(outimgs, 3, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
|
||||||
end
|
|
||||||
|
|
||||||
local pname = xm..xp..ym..yp..zm..zp
|
|
||||||
local pgroups = ""
|
|
||||||
|
|
||||||
if pname ~= "110000" then
|
|
||||||
pgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
|
|
||||||
pipedesc = "Pipe segment (empty, "..pname..")... You hacker, you."
|
|
||||||
image = "pipeworks_plain.png"
|
|
||||||
else
|
|
||||||
pgroups = {snappy=3, pipe=1}
|
|
||||||
pipedesc = "Pipe segment"
|
|
||||||
image = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("pipeworks:pipe_"..pname.."_empty", {
|
|
||||||
description = pipedesc,
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = pipes_fix_image_names(outimgs, "_empty"),
|
|
||||||
inventory_image = image,
|
|
||||||
sunlight_propagates=true,
|
|
||||||
paramtype = "light",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = outsel
|
|
||||||
},
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = outboxes
|
|
||||||
},
|
|
||||||
groups = pgroups,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
walkable = true,
|
|
||||||
drop = "pipeworks:pipe_110000_empty",
|
|
||||||
after_place_node = function(pos)
|
|
||||||
pipe_scanforobjects(pos)
|
|
||||||
end,
|
|
||||||
after_dig_node = function(pos)
|
|
||||||
pipe_scanforobjects(pos)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("pipeworks:pipe_"..pname.."_loaded", {
|
|
||||||
description = "Pipe segment (loaded, "..pname..")... You hacker, you.",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = pipes_fix_image_names(outimgs, "_loaded"),
|
|
||||||
inventory_image = image,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
paramtype = "light",
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = outsel
|
|
||||||
},
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = outboxes
|
|
||||||
},
|
|
||||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
walkable = true,
|
|
||||||
drop = "pipeworks:pipe_110000_empty",
|
|
||||||
after_place_node = function(pos)
|
|
||||||
pipe_scanforobjects(pos)
|
|
||||||
end,
|
|
||||||
after_dig_node = function(pos)
|
|
||||||
pipe_scanforobjects(pos)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:pipe_"..pname.."_empty") -- for the abms
|
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:pipe_"..pname.."_loaded") -- for bacon
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local modpath = minetest.get_modpath("pipeworks")
|
-- Load the various parts of the mod
|
||||||
|
|
||||||
|
dofile(modpath.."/autoplace.lua")
|
||||||
|
dofile(modpath.."/item_transport.lua")
|
||||||
|
dofile(modpath.."/flowing_logic.lua")
|
||||||
|
dofile(modpath.."/crafts.lua")
|
||||||
|
|
||||||
dofile(modpath.."/tubes.lua")
|
dofile(modpath.."/tubes.lua")
|
||||||
dofile(modpath.."/teleport_tube.lua")
|
|
||||||
dofile(modpath.."/devices.lua")
|
if enable_pipes then dofile(modpath.."/pipes.lua") end
|
||||||
dofile(modpath.."/autoplace.lua")
|
if enable_teleport_tube then dofile(modpath.."/teleport_tube.lua") end
|
||||||
dofile(modpath.."/crafts.lua")
|
if enable_pipe_devices then dofile(modpath.."/devices.lua") end
|
||||||
dofile(modpath.."/flowing_logic.lua")
|
if enable_redefines then dofile(modpath.."/compat.lua") end
|
||||||
dofile(modpath.."/compat.lua")
|
if enable_autocrafter then dofile(modpath.."/autocrafter.lua") end
|
||||||
dofile(modpath.."/item_transport.lua")
|
if enable_deployer then dofile(modpath.."/deployer.lua") end
|
||||||
dofile(modpath.."/autocrafter.lua")
|
if enable_node_breaker then dofile(modpath.."/node_breaker.lua") end
|
||||||
dofile(modpath.."/deployer.lua")
|
|
||||||
dofile(modpath.."/node_breaker.lua")
|
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
||||||
|
local DEBUG = false
|
||||||
|
local CYCLIC = true
|
||||||
|
|
||||||
print("Pipeworks loaded!")
|
print("Pipeworks loaded!")
|
||||||
|
314
pipes.lua
Normal file
314
pipes.lua
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
pipeworks_liquid_texture = "default_water.png"
|
||||||
|
|
||||||
|
pipe_leftstub = {
|
||||||
|
{ -32/64, -2/64, -6/64, 1/64, 2/64, 6/64 }, -- pipe segment against -X face
|
||||||
|
{ -32/64, -4/64, -5/64, 1/64, 4/64, 5/64 },
|
||||||
|
{ -32/64, -5/64, -4/64, 1/64, 5/64, 4/64 },
|
||||||
|
{ -32/64, -6/64, -2/64, 1/64, 6/64, 2/64 },
|
||||||
|
|
||||||
|
{ -32/64, -3/64, -8/64, -30/64, 3/64, 8/64 }, -- (the flange for it)
|
||||||
|
{ -32/64, -5/64, -7/64, -30/64, 5/64, 7/64 },
|
||||||
|
{ -32/64, -6/64, -6/64, -30/64, 6/64, 6/64 },
|
||||||
|
{ -32/64, -7/64, -5/64, -30/64, 7/64, 5/64 },
|
||||||
|
{ -32/64, -8/64, -3/64, -30/64, 8/64, 3/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_rightstub = {
|
||||||
|
{ -1/64, -2/64, -6/64, 32/64, 2/64, 6/64 }, -- pipe segment against +X face
|
||||||
|
{ -1/64, -4/64, -5/64, 32/64, 4/64, 5/64 },
|
||||||
|
{ -1/64, -5/64, -4/64, 32/64, 5/64, 4/64 },
|
||||||
|
{ -1/64, -6/64, -2/64, 32/64, 6/64, 2/64 },
|
||||||
|
|
||||||
|
{ 30/64, -3/64, -8/64, 32/64, 3/64, 8/64 }, -- (the flange for it)
|
||||||
|
{ 30/64, -5/64, -7/64, 32/64, 5/64, 7/64 },
|
||||||
|
{ 30/64, -6/64, -6/64, 32/64, 6/64, 6/64 },
|
||||||
|
{ 30/64, -7/64, -5/64, 32/64, 7/64, 5/64 },
|
||||||
|
{ 30/64, -8/64, -3/64, 32/64, 8/64, 3/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_bottomstub = {
|
||||||
|
{ -2/64, -32/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
|
||||||
|
{ -4/64, -32/64, -5/64, 4/64, 1/64, 5/64 },
|
||||||
|
{ -5/64, -32/64, -4/64, 5/64, 1/64, 4/64 },
|
||||||
|
{ -6/64, -32/64, -2/64, 6/64, 1/64, 2/64 },
|
||||||
|
|
||||||
|
{ -3/64, -32/64, -8/64, 3/64, -30/64, 8/64 }, -- (the flange for it)
|
||||||
|
{ -5/64, -32/64, -7/64, 5/64, -30/64, 7/64 },
|
||||||
|
{ -6/64, -32/64, -6/64, 6/64, -30/64, 6/64 },
|
||||||
|
{ -7/64, -32/64, -5/64, 7/64, -30/64, 5/64 },
|
||||||
|
{ -8/64, -32/64, -3/64, 8/64, -30/64, 3/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pipe_topstub = {
|
||||||
|
{ -2/64, -1/64, -6/64, 2/64, 32/64, 6/64 }, -- pipe segment against +Y face
|
||||||
|
{ -4/64, -1/64, -5/64, 4/64, 32/64, 5/64 },
|
||||||
|
{ -5/64, -1/64, -4/64, 5/64, 32/64, 4/64 },
|
||||||
|
{ -6/64, -1/64, -2/64, 6/64, 32/64, 2/64 },
|
||||||
|
|
||||||
|
{ -3/64, 30/64, -8/64, 3/64, 32/64, 8/64 }, -- (the flange for it)
|
||||||
|
{ -5/64, 30/64, -7/64, 5/64, 32/64, 7/64 },
|
||||||
|
{ -6/64, 30/64, -6/64, 6/64, 32/64, 6/64 },
|
||||||
|
{ -7/64, 30/64, -5/64, 7/64, 32/64, 5/64 },
|
||||||
|
{ -8/64, 30/64, -3/64, 8/64, 32/64, 3/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_frontstub = {
|
||||||
|
{ -6/64, -2/64, -32/64, 6/64, 2/64, 1/64 }, -- pipe segment against -Z face
|
||||||
|
{ -5/64, -4/64, -32/64, 5/64, 4/64, 1/64 },
|
||||||
|
{ -4/64, -5/64, -32/64, 4/64, 5/64, 1/64 },
|
||||||
|
{ -2/64, -6/64, -32/64, 2/64, 6/64, 1/64 },
|
||||||
|
|
||||||
|
{ -8/64, -3/64, -32/64, 8/64, 3/64, -30/64 }, -- (the flange for it)
|
||||||
|
{ -7/64, -5/64, -32/64, 7/64, 5/64, -30/64 },
|
||||||
|
{ -6/64, -6/64, -32/64, 6/64, 6/64, -30/64 },
|
||||||
|
{ -5/64, -7/64, -32/64, 5/64, 7/64, -30/64 },
|
||||||
|
{ -3/64, -8/64, -32/64, 3/64, 8/64, -30/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_backstub = {
|
||||||
|
{ -6/64, -2/64, -1/64, 6/64, 2/64, 32/64 }, -- pipe segment against -Z face
|
||||||
|
{ -5/64, -4/64, -1/64, 5/64, 4/64, 32/64 },
|
||||||
|
{ -4/64, -5/64, -1/64, 4/64, 5/64, 32/64 },
|
||||||
|
{ -2/64, -6/64, -1/64, 2/64, 6/64, 32/64 },
|
||||||
|
|
||||||
|
{ -8/64, -3/64, 30/64, 8/64, 3/64, 32/64 }, -- (the flange for it)
|
||||||
|
{ -7/64, -5/64, 30/64, 7/64, 5/64, 32/64 },
|
||||||
|
{ -6/64, -6/64, 30/64, 6/64, 6/64, 32/64 },
|
||||||
|
{ -5/64, -7/64, 30/64, 5/64, 7/64, 32/64 },
|
||||||
|
{ -3/64, -8/64, 30/64, 3/64, 8/64, 32/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_selectboxes = {
|
||||||
|
{ -32/64, -8/64, -8/64, 8/64, 8/64, 8/64 },
|
||||||
|
{ -8/64 , -8/64, -8/64, 32/64, 8/64, 8/64 },
|
||||||
|
{ -8/64 , -32/64, -8/64, 8/64, 8/64, 8/64 },
|
||||||
|
{ -8/64 , -8/64, -8/64, 8/64, 32/64, 8/64 },
|
||||||
|
{ -8/64 , -8/64, -32/64, 8/64, 8/64, 8/64 },
|
||||||
|
{ -8/64 , -8/64, -8/64, 8/64, 8/64, 32/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_bendsphere = {
|
||||||
|
{ -4/64, -4/64, -4/64, 4/64, 4/64, 4/64 },
|
||||||
|
{ -5/64, -3/64, -3/64, 5/64, 3/64, 3/64 },
|
||||||
|
{ -3/64, -5/64, -3/64, 3/64, 5/64, 3/64 },
|
||||||
|
{ -3/64, -3/64, -5/64, 3/64, 3/64, 5/64 }
|
||||||
|
}
|
||||||
|
|
||||||
|
-- now define the nodes!
|
||||||
|
|
||||||
|
pipes_empty_nodenames = {}
|
||||||
|
pipes_full_nodenames = {}
|
||||||
|
|
||||||
|
for xm = 0, 1 do
|
||||||
|
for xp = 0, 1 do
|
||||||
|
for ym = 0, 1 do
|
||||||
|
for yp = 0, 1 do
|
||||||
|
for zm = 0, 1 do
|
||||||
|
for zp = 0, 1 do
|
||||||
|
local outboxes = {}
|
||||||
|
local outsel = {}
|
||||||
|
local outimgs = {}
|
||||||
|
|
||||||
|
if yp==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_topstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[4])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if ym==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_bottomstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[3])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if xp==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_rightstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[2])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if xm==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_leftstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[1])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if zp==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_backstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[6])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if zm==1 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_frontstub)
|
||||||
|
table.insert(outsel, pipe_selectboxes[5])
|
||||||
|
table.insert(outimgs, "pipeworks_pipe_end.png")
|
||||||
|
else
|
||||||
|
table.insert(outimgs, "pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
|
||||||
|
local jx = xp+xm
|
||||||
|
local jy = yp+ym
|
||||||
|
local jz = zp+zm
|
||||||
|
|
||||||
|
if (jx+jy+jz) == 1 then
|
||||||
|
if xm == 1 then
|
||||||
|
table.remove(outimgs, 3)
|
||||||
|
table.insert(outimgs, 3, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if xp == 1 then
|
||||||
|
table.remove(outimgs, 4)
|
||||||
|
table.insert(outimgs, 4, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if ym == 1 then
|
||||||
|
table.remove(outimgs, 1)
|
||||||
|
table.insert(outimgs, 1, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if xp == 1 then
|
||||||
|
table.remove(outimgs, 2)
|
||||||
|
table.insert(outimgs, 2, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if zm == 1 then
|
||||||
|
table.remove(outimgs, 5)
|
||||||
|
table.insert(outimgs, 5, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
if zp == 1 then
|
||||||
|
table.remove(outimgs, 6)
|
||||||
|
table.insert(outimgs, 6, "^pipeworks_plain.png")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if jx+jy+jz >= 2 then
|
||||||
|
pipeworks_add_pipebox(outboxes, pipe_bendsphere)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (jx==2 and jy~=2 and jz~=2) then
|
||||||
|
table.remove(outimgs, 5)
|
||||||
|
table.remove(outimgs, 5)
|
||||||
|
table.insert(outimgs, 5, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
||||||
|
table.insert(outimgs, 5, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
||||||
|
end
|
||||||
|
|
||||||
|
if (jx~=2 and jy~=2 and jz==2) or (jx~=2 and jy==2 and jz~=2) then
|
||||||
|
table.remove(outimgs, 3)
|
||||||
|
table.remove(outimgs, 3)
|
||||||
|
table.insert(outimgs, 3, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
||||||
|
table.insert(outimgs, 3, pipeworks_liquid_texture.."^pipeworks_windowed_XXXXX.png")
|
||||||
|
end
|
||||||
|
|
||||||
|
local pname = xm..xp..ym..yp..zm..zp
|
||||||
|
local pgroups = ""
|
||||||
|
|
||||||
|
if pname ~= "110000" then
|
||||||
|
pgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
|
||||||
|
pipedesc = "Pipe segment (empty, "..pname..")... You hacker, you."
|
||||||
|
image = "pipeworks_plain.png"
|
||||||
|
else
|
||||||
|
pgroups = {snappy=3, pipe=1}
|
||||||
|
pipedesc = "Pipe segment"
|
||||||
|
image = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("pipeworks:pipe_"..pname.."_empty", {
|
||||||
|
description = pipedesc,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = pipeworks_fix_image_names(outimgs, "_empty"),
|
||||||
|
inventory_image = image,
|
||||||
|
sunlight_propagates=true,
|
||||||
|
paramtype = "light",
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = outsel
|
||||||
|
},
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = outboxes
|
||||||
|
},
|
||||||
|
groups = pgroups,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
walkable = true,
|
||||||
|
drop = "pipeworks:pipe_110000_empty",
|
||||||
|
after_place_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("pipeworks:pipe_"..pname.."_loaded", {
|
||||||
|
description = "Pipe segment (loaded, "..pname..")... You hacker, you.",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = pipeworks_fix_image_names(outimgs, "_loaded"),
|
||||||
|
inventory_image = image,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype = "light",
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = outsel
|
||||||
|
},
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = outboxes
|
||||||
|
},
|
||||||
|
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
walkable = true,
|
||||||
|
drop = "pipeworks:pipe_110000_empty",
|
||||||
|
after_place_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:pipe_"..pname.."_empty") -- for the abms
|
||||||
|
table.insert(pipes_full_nodenames,"pipeworks:pipe_"..pname.."_loaded") -- for bacon
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_empty")
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:flow_sensor_empty")
|
||||||
|
|
||||||
|
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
|
||||||
|
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
|
||||||
|
table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = pipes_empty_nodenames,
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
pipeworks_check_for_inflows(pos,node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = pipes_full_nodenames,
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
pipeworks_check_sources(pos,node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
pipeworks_spigot_check(pos,node)
|
||||||
|
end
|
||||||
|
})
|
632
tubes.lua
632
tubes.lua
@ -1,35 +1,4 @@
|
|||||||
-- This file supplies pneumatic tubes and a 'test' device
|
-- This file supplies the various kinds of pneumatic tubes
|
||||||
|
|
||||||
minetest.register_node("pipeworks:testobject", {
|
|
||||||
description = "Pneumatic tube test object",
|
|
||||||
tiles = {
|
|
||||||
"pipeworks_testobject.png",
|
|
||||||
},
|
|
||||||
paramtype = "light",
|
|
||||||
groups = {snappy=3, tubedevice=1},
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
walkable = true,
|
|
||||||
after_place_node = function(pos)
|
|
||||||
tube_scanforobjects(pos)
|
|
||||||
end,
|
|
||||||
after_dig_node = function(pos)
|
|
||||||
tube_scanforobjects(pos)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
function replace_name(tbl,tr,name)
|
|
||||||
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
|
|
||||||
ntbl[key]=replace_name(i,tr,name)
|
|
||||||
else
|
|
||||||
ntbl[key]=i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ntbl
|
|
||||||
end
|
|
||||||
|
|
||||||
tubenodes={}
|
tubenodes={}
|
||||||
|
|
||||||
@ -242,7 +211,7 @@ for zp = 0, 1 do
|
|||||||
nodedef.groups[group]=val
|
nodedef.groups[group]=val
|
||||||
end
|
end
|
||||||
elseif type(value)=="table" then
|
elseif type(value)=="table" then
|
||||||
nodedef[key]=replace_name(value,"#id",tname)
|
nodedef[key]=pipeworks_replace_name(value,"#id",tname)
|
||||||
elseif type(value)=="string" then
|
elseif type(value)=="string" then
|
||||||
nodedef[key]=string.gsub(value,"#id",tname)
|
nodedef[key]=string.gsub(value,"#id",tname)
|
||||||
else
|
else
|
||||||
@ -263,6 +232,7 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
noctr_textures={"pipeworks_tube_noctr.png","pipeworks_tube_noctr.png","pipeworks_tube_noctr.png",
|
noctr_textures={"pipeworks_tube_noctr.png","pipeworks_tube_noctr.png","pipeworks_tube_noctr.png",
|
||||||
"pipeworks_tube_noctr.png","pipeworks_tube_noctr.png","pipeworks_tube_noctr.png"}
|
"pipeworks_tube_noctr.png","pipeworks_tube_noctr.png","pipeworks_tube_noctr.png"}
|
||||||
plain_textures={"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png",
|
plain_textures={"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png",
|
||||||
@ -274,306 +244,332 @@ inv_texture="pipeworks_tube_inv.png"
|
|||||||
|
|
||||||
register_tube("pipeworks:tube","Pneumatic tube segment",plain_textures,noctr_textures,end_textures,short_texture,inv_texture)
|
register_tube("pipeworks:tube","Pneumatic tube segment",plain_textures,noctr_textures,end_textures,short_texture,inv_texture)
|
||||||
|
|
||||||
mese_noctr_textures={"pipeworks_mese_tube_noctr_1.png","pipeworks_mese_tube_noctr_2.png","pipeworks_mese_tube_noctr_3.png",
|
|
||||||
"pipeworks_mese_tube_noctr_4.png","pipeworks_mese_tube_noctr_5.png","pipeworks_mese_tube_noctr_6.png"}
|
|
||||||
|
|
||||||
mese_plain_textures={"pipeworks_mese_tube_plain_1.png","pipeworks_mese_tube_plain_2.png","pipeworks_mese_tube_plain_3.png",
|
|
||||||
"pipeworks_mese_tube_plain_4.png","pipeworks_mese_tube_plain_5.png","pipeworks_mese_tube_plain_6.png"}
|
|
||||||
mese_end_textures={"pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png",
|
|
||||||
"pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png"}
|
|
||||||
mese_short_texture="pipeworks_mese_tube_short.png"
|
|
||||||
mese_inv_texture="pipeworks_mese_tube_inv.png"
|
|
||||||
|
|
||||||
detector_plain_textures={"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png",
|
if enable_mese_tube then
|
||||||
"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png"}
|
|
||||||
detector_inv_texture="pipeworks_detector_tube_inv.png"
|
|
||||||
|
|
||||||
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}}
|
mese_noctr_textures={"pipeworks_mese_tube_noctr_1.png","pipeworks_mese_tube_noctr_2.png","pipeworks_mese_tube_noctr_3.png",
|
||||||
|
"pipeworks_mese_tube_noctr_4.png","pipeworks_mese_tube_noctr_5.png","pipeworks_mese_tube_noctr_6.png"}
|
||||||
|
mese_plain_textures={"pipeworks_mese_tube_plain_1.png","pipeworks_mese_tube_plain_2.png","pipeworks_mese_tube_plain_3.png",
|
||||||
|
"pipeworks_mese_tube_plain_4.png","pipeworks_mese_tube_plain_5.png","pipeworks_mese_tube_plain_6.png"}
|
||||||
|
mese_end_textures={"pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png",
|
||||||
|
"pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png","pipeworks_mese_tube_end.png"}
|
||||||
|
mese_short_texture="pipeworks_mese_tube_short.png"
|
||||||
|
mese_inv_texture="pipeworks_mese_tube_inv.png"
|
||||||
|
|
||||||
register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_textures,mese_noctr_textures,
|
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}}
|
||||||
mese_end_textures,mese_short_texture,mese_inv_texture,
|
|
||||||
{tube={can_go=function(pos,node,velocity,stack)
|
register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_textures,mese_noctr_textures,
|
||||||
tbl={}
|
mese_end_textures,mese_short_texture,mese_inv_texture,
|
||||||
local meta=minetest.get_meta(pos)
|
{tube={can_go=function(pos,node,velocity,stack)
|
||||||
local inv=meta:get_inventory()
|
tbl={}
|
||||||
local found=false
|
local meta=minetest.get_meta(pos)
|
||||||
local name=stack:get_name()
|
local inv=meta:get_inventory()
|
||||||
for i,vect in ipairs(meseadjlist) do
|
local found=false
|
||||||
if meta:get_int("l"..tostring(i).."s")==1 then
|
local name=stack:get_name()
|
||||||
for _,st in ipairs(inv:get_list("line"..tostring(i))) do
|
|
||||||
if st:get_name()==name then
|
|
||||||
found=true
|
|
||||||
table.insert(tbl,vect)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if found==false then
|
|
||||||
for i,vect in ipairs(meseadjlist) do
|
for i,vect in ipairs(meseadjlist) do
|
||||||
if meta:get_int("l"..tostring(i).."s")==1 then
|
if meta:get_int("l"..tostring(i).."s")==1 then
|
||||||
if inv:is_empty("line"..tostring(i)) then
|
for _,st in ipairs(inv:get_list("line"..tostring(i))) do
|
||||||
table.insert(tbl,vect)
|
if st:get_name()==name then
|
||||||
|
found=true
|
||||||
|
table.insert(tbl,vect)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
if found==false then
|
||||||
return tbl
|
for i,vect in ipairs(meseadjlist) do
|
||||||
end},
|
if meta:get_int("l"..tostring(i).."s")==1 then
|
||||||
on_construct = function(pos)
|
if inv:is_empty("line"..tostring(i)) then
|
||||||
local meta = minetest.get_meta(pos)
|
table.insert(tbl,vect)
|
||||||
local inv = meta:get_inventory()
|
end
|
||||||
for i=1,6 do
|
end
|
||||||
meta:set_int("l"..tostring(i).."s",1)
|
|
||||||
inv:set_size("line"..tostring(i), 6*1)
|
|
||||||
end
|
|
||||||
meta:set_string("formspec",
|
|
||||||
"size[8,11]"..
|
|
||||||
"list[current_name;line1;1,0;6,1;]"..
|
|
||||||
"list[current_name;line2;1,1;6,1;]"..
|
|
||||||
"list[current_name;line3;1,2;6,1;]"..
|
|
||||||
"list[current_name;line4;1,3;6,1;]"..
|
|
||||||
"list[current_name;line5;1,4;6,1;]"..
|
|
||||||
"list[current_name;line6;1,5;6,1;]"..
|
|
||||||
"image[0,0;1,1;pipeworks_white.png]"..
|
|
||||||
"image[0,1;1,1;pipeworks_black.png]"..
|
|
||||||
"image[0,2;1,1;pipeworks_green.png]"..
|
|
||||||
"image[0,3;1,1;pipeworks_yellow.png]"..
|
|
||||||
"image[0,4;1,1;pipeworks_blue.png]"..
|
|
||||||
"image[0,5;1,1;pipeworks_red.png]"..
|
|
||||||
"button[7,0;1,1;button1;On]"..
|
|
||||||
"button[7,1;1,1;button2;On]"..
|
|
||||||
"button[7,2;1,1;button3;On]"..
|
|
||||||
"button[7,3;1,1;button4;On]"..
|
|
||||||
"button[7,4;1,1;button5;On]"..
|
|
||||||
"button[7,5;1,1;button6;On]"..
|
|
||||||
"list[current_player;main;0,7;8,4;]")
|
|
||||||
meta:set_string("infotext", "Mese pneumatic tube")
|
|
||||||
end,
|
|
||||||
on_receive_fields=function(pos,formname,fields,sender)
|
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
local i
|
|
||||||
for key,_ in pairs(fields) do i=key end
|
|
||||||
if i==nil then return end
|
|
||||||
i=string.sub(i,-1)
|
|
||||||
newstate=1-meta:get_int("l"..i.."s")
|
|
||||||
meta:set_int("l"..i.."s",newstate)
|
|
||||||
local frm="size[8,11]"..
|
|
||||||
"list[current_name;line1;1,0;6,1;]"..
|
|
||||||
"list[current_name;line2;1,1;6,1;]"..
|
|
||||||
"list[current_name;line3;1,2;6,1;]"..
|
|
||||||
"list[current_name;line4;1,3;6,1;]"..
|
|
||||||
"list[current_name;line5;1,4;6,1;]"..
|
|
||||||
"list[current_name;line6;1,5;6,1;]"..
|
|
||||||
"image[0,0;1,1;pipeworks_white.png]"..
|
|
||||||
"image[0,1;1,1;pipeworks_black.png]"..
|
|
||||||
"image[0,2;1,1;pipeworks_green.png]"..
|
|
||||||
"image[0,3;1,1;pipeworks_yellow.png]"..
|
|
||||||
"image[0,4;1,1;pipeworks_blue.png]"..
|
|
||||||
"image[0,5;1,1;pipeworks_red.png]"
|
|
||||||
for i=1,6 do
|
|
||||||
local st=meta:get_int("l"..tostring(i).."s")
|
|
||||||
if st==0 then
|
|
||||||
frm=frm.."button[7,"..tostring(i-1)..";1,1;button"..tostring(i)..";Off]"
|
|
||||||
else
|
|
||||||
frm=frm.."button[7,"..tostring(i-1)..";1,1;button"..tostring(i)..";On]"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
frm=frm.."list[current_player;main;0,7;8,4;]"
|
|
||||||
meta:set_string("formspec",frm)
|
|
||||||
end,
|
|
||||||
can_dig = function(pos,player)
|
|
||||||
local meta = minetest.get_meta(pos);
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return (inv:is_empty("line1") and inv:is_empty("line2") and inv:is_empty("line3") and
|
|
||||||
inv:is_empty("line4") and inv:is_empty("line5") and inv:is_empty("line6"))
|
|
||||||
end})
|
|
||||||
|
|
||||||
|
|
||||||
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}}
|
|
||||||
|
|
||||||
register_tube("pipeworks:detector_tube_on","Detector tube segment on (you hacker you)",detector_plain_textures,noctr_textures,
|
|
||||||
end_textures,short_texture,detector_inv_texture,
|
|
||||||
{tube={can_go=function(pos,node,velocity,stack)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
local nitems=meta:get_int("nitems")+1
|
|
||||||
meta:set_int("nitems", nitems)
|
|
||||||
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
|
|
||||||
return notvel(meseadjlist,velocity)
|
|
||||||
end},
|
|
||||||
groups={mesecon=2,not_in_creative_inventory=1},
|
|
||||||
drop="pipeworks:detector_tube_off_000000",
|
|
||||||
mesecons={receptor={state="on",
|
|
||||||
rules=mesecons_rules}},
|
|
||||||
item_exit = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local nitems=meta:get_int("nitems")-1
|
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
if nitems==0 then
|
|
||||||
minetest.set_node(pos,{name=string.gsub(name,"on","off")})
|
|
||||||
mesecon:receptor_off(pos,mesecons_rules)
|
|
||||||
else
|
|
||||||
meta:set_int("nitems", nitems)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("nitems", 1)
|
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
|
|
||||||
end})
|
|
||||||
|
|
||||||
register_tube("pipeworks:detector_tube_off","Detector tube segment",detector_plain_textures,noctr_textures,
|
|
||||||
end_textures,short_texture,detector_inv_texture,
|
|
||||||
{tube={can_go=function(pos,node,velocity,stack)
|
|
||||||
local name = minetest.get_node(pos).name
|
|
||||||
minetest.set_node(pos,{name=string.gsub(name,"off","on")})
|
|
||||||
mesecon:receptor_on(pos,mesecons_rules)
|
|
||||||
return notvel(meseadjlist,velocity)
|
|
||||||
end},
|
|
||||||
groups={mesecon=2},
|
|
||||||
mesecons={receptor={state="off",
|
|
||||||
rules=mesecons_rules}}})
|
|
||||||
|
|
||||||
conductor_plain_textures={"pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png",
|
|
||||||
"pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png"}
|
|
||||||
conductor_noctr_textures={"pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png",
|
|
||||||
"pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png"}
|
|
||||||
conductor_end_textures={"pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png",
|
|
||||||
"pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png"}
|
|
||||||
conductor_short_texture="pipeworks_conductor_tube_short.png"
|
|
||||||
conductor_inv_texture="pipeworks_conductor_tube_inv.png"
|
|
||||||
|
|
||||||
register_tube("pipeworks:conductor_tube_off","Conductor tube segment",conductor_plain_textures,conductor_noctr_textures,
|
|
||||||
conductor_end_textures,conductor_short_texture,conductor_inv_texture,
|
|
||||||
{groups={mesecon=2},
|
|
||||||
mesecons={conductor={state="off",
|
|
||||||
rules=mesecons_rules,
|
|
||||||
onstate="pipeworks:conductor_tube_on_#id"}}})
|
|
||||||
|
|
||||||
conductor_on_plain_textures={"pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png",
|
|
||||||
"pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png"}
|
|
||||||
conductor_on_noctr_textures={"pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png",
|
|
||||||
"pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png"}
|
|
||||||
conductor_on_end_textures={"pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png",
|
|
||||||
"pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png"}
|
|
||||||
|
|
||||||
register_tube("pipeworks:conductor_tube_on","Conductor tube segment on (you hacker you)",conductor_on_plain_textures,conductor_on_noctr_textures,
|
|
||||||
conductor_on_end_textures,conductor_short_texture,conductor_inv_texture,
|
|
||||||
{groups={mesecon=2,not_in_creative_inventory=1},
|
|
||||||
drop="pipeworks:conductor_tube_off_000000",
|
|
||||||
mesecons={conductor={state="on",
|
|
||||||
rules=mesecons_rules,
|
|
||||||
offstate="pipeworks:conductor_tube_off_#id"}}})
|
|
||||||
|
|
||||||
accelerator_noctr_textures={"pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png",
|
|
||||||
"pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png"}
|
|
||||||
accelerator_plain_textures={"pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png",
|
|
||||||
"pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png"}
|
|
||||||
accelerator_end_textures={"pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png",
|
|
||||||
"pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png"}
|
|
||||||
accelerator_short_texture="pipeworks_accelerator_tube_short.png"
|
|
||||||
accelerator_inv_texture="pipeworks_accelerator_tube_inv.png"
|
|
||||||
|
|
||||||
register_tube("pipeworks:accelerator_tube","Accelerator pneumatic tube segment",accelerator_plain_textures,
|
|
||||||
accelerator_noctr_textures,accelerator_end_textures,accelerator_short_texture,accelerator_inv_texture,
|
|
||||||
{tube={can_go=function(pos,node,velocity,stack)
|
|
||||||
velocity.speed=velocity.speed+1
|
|
||||||
return notvel(meseadjlist,velocity)
|
|
||||||
end}})
|
|
||||||
|
|
||||||
register_tube("pipeworks:crossing_tube","Crossing tube segment",accelerator_plain_textures,
|
|
||||||
accelerator_noctr_textures,accelerator_end_textures,accelerator_short_texture,accelerator_inv_texture,
|
|
||||||
{tube={can_go=function(pos,node,velocity,stack)
|
|
||||||
return velocity
|
|
||||||
end}})
|
|
||||||
|
|
||||||
sand_noctr_textures={"pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png",
|
|
||||||
"pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png"}
|
|
||||||
sand_plain_textures={"pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png",
|
|
||||||
"pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png"}
|
|
||||||
sand_end_textures={"pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png",
|
|
||||||
"pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png"}
|
|
||||||
sand_short_texture="pipeworks_sand_tube_short.png"
|
|
||||||
sand_inv_texture="pipeworks_sand_tube_inv.png"
|
|
||||||
|
|
||||||
register_tube("pipeworks:sand_tube","Sand pneumatic tube segment",sand_plain_textures,sand_noctr_textures,sand_end_textures,
|
|
||||||
sand_short_texture,sand_inv_texture,
|
|
||||||
{groups={sand_tube=1}})
|
|
||||||
|
|
||||||
minetest.register_abm({nodenames={"group:sand_tube"},interval=1,chance=1,
|
|
||||||
action=function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
|
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
|
||||||
if object:get_luaentity().itemstring ~= "" then
|
|
||||||
local titem=tube_item(pos,object:get_luaentity().itemstring)
|
|
||||||
titem:get_luaentity().start_pos = {x=pos.x,y=pos.y-1,z=pos.z}
|
|
||||||
titem:setvelocity({x=0.01,y=1,z=-0.01})
|
|
||||||
titem:setacceleration({x=0, y=0, z=0})
|
|
||||||
end
|
end
|
||||||
object:get_luaentity().itemstring = ""
|
|
||||||
object:remove()
|
|
||||||
end
|
end
|
||||||
|
return tbl
|
||||||
|
end},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
for i=1,6 do
|
||||||
|
meta:set_int("l"..tostring(i).."s",1)
|
||||||
|
inv:set_size("line"..tostring(i), 6*1)
|
||||||
|
end
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"size[8,11]"..
|
||||||
|
"list[current_name;line1;1,0;6,1;]"..
|
||||||
|
"list[current_name;line2;1,1;6,1;]"..
|
||||||
|
"list[current_name;line3;1,2;6,1;]"..
|
||||||
|
"list[current_name;line4;1,3;6,1;]"..
|
||||||
|
"list[current_name;line5;1,4;6,1;]"..
|
||||||
|
"list[current_name;line6;1,5;6,1;]"..
|
||||||
|
"image[0,0;1,1;pipeworks_white.png]"..
|
||||||
|
"image[0,1;1,1;pipeworks_black.png]"..
|
||||||
|
"image[0,2;1,1;pipeworks_green.png]"..
|
||||||
|
"image[0,3;1,1;pipeworks_yellow.png]"..
|
||||||
|
"image[0,4;1,1;pipeworks_blue.png]"..
|
||||||
|
"image[0,5;1,1;pipeworks_red.png]"..
|
||||||
|
"button[7,0;1,1;button1;On]"..
|
||||||
|
"button[7,1;1,1;button2;On]"..
|
||||||
|
"button[7,2;1,1;button3;On]"..
|
||||||
|
"button[7,3;1,1;button4;On]"..
|
||||||
|
"button[7,4;1,1;button5;On]"..
|
||||||
|
"button[7,5;1,1;button6;On]"..
|
||||||
|
"list[current_player;main;0,7;8,4;]")
|
||||||
|
meta:set_string("infotext", "Mese pneumatic tube")
|
||||||
|
end,
|
||||||
|
on_receive_fields=function(pos,formname,fields,sender)
|
||||||
|
local meta=minetest.get_meta(pos)
|
||||||
|
local i
|
||||||
|
for key,_ in pairs(fields) do i=key end
|
||||||
|
if i==nil then return end
|
||||||
|
i=string.sub(i,-1)
|
||||||
|
newstate=1-meta:get_int("l"..i.."s")
|
||||||
|
meta:set_int("l"..i.."s",newstate)
|
||||||
|
local frm="size[8,11]"..
|
||||||
|
"list[current_name;line1;1,0;6,1;]"..
|
||||||
|
"list[current_name;line2;1,1;6,1;]"..
|
||||||
|
"list[current_name;line3;1,2;6,1;]"..
|
||||||
|
"list[current_name;line4;1,3;6,1;]"..
|
||||||
|
"list[current_name;line5;1,4;6,1;]"..
|
||||||
|
"list[current_name;line6;1,5;6,1;]"..
|
||||||
|
"image[0,0;1,1;pipeworks_white.png]"..
|
||||||
|
"image[0,1;1,1;pipeworks_black.png]"..
|
||||||
|
"image[0,2;1,1;pipeworks_green.png]"..
|
||||||
|
"image[0,3;1,1;pipeworks_yellow.png]"..
|
||||||
|
"image[0,4;1,1;pipeworks_blue.png]"..
|
||||||
|
"image[0,5;1,1;pipeworks_red.png]"
|
||||||
|
for i=1,6 do
|
||||||
|
local st=meta:get_int("l"..tostring(i).."s")
|
||||||
|
if st==0 then
|
||||||
|
frm=frm.."button[7,"..tostring(i-1)..";1,1;button"..tostring(i)..";Off]"
|
||||||
|
else
|
||||||
|
frm=frm.."button[7,"..tostring(i-1)..";1,1;button"..tostring(i)..";On]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
frm=frm.."list[current_player;main;0,7;8,4;]"
|
||||||
|
meta:set_string("formspec",frm)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return (inv:is_empty("line1") and inv:is_empty("line2") and inv:is_empty("line3") and
|
||||||
|
inv:is_empty("line4") and inv:is_empty("line5") and inv:is_empty("line6"))
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
})
|
|
||||||
|
|
||||||
mese_sand_noctr_textures={"pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png",
|
|
||||||
"pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png"}
|
|
||||||
mese_sand_plain_textures={"pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png",
|
|
||||||
"pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png"}
|
|
||||||
mese_sand_end_textures={"pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png",
|
|
||||||
"pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png"}
|
|
||||||
mese_sand_short_texture="pipeworks_mese_sand_tube_short.png"
|
|
||||||
mese_sand_inv_texture="pipeworks_mese_sand_tube_inv.png"
|
|
||||||
|
|
||||||
register_tube("pipeworks:mese_sand_tube","Mese sand pneumatic tube segment",mese_sand_plain_textures,mese_sand_noctr_textures,mese_sand_end_textures,
|
|
||||||
mese_sand_short_texture,mese_sand_inv_texture,
|
|
||||||
{groups={mese_sand_tube=1},
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
meta:set_int("dist", 0)
|
|
||||||
meta:set_string("formspec",
|
|
||||||
"size[2,1]"..
|
|
||||||
"field[.5,.5;1.5,1;dist;distance;${dist}]")
|
|
||||||
meta:set_string("infotext", "Mese sand pneumatic tube")
|
|
||||||
end,
|
|
||||||
on_receive_fields=function(pos,formname,fields,sender)
|
|
||||||
local meta=minetest.env:get_meta(pos)
|
|
||||||
local dist
|
|
||||||
_, dist = pcall(tonumber, fields.dist)
|
|
||||||
if dist and 0 <= dist and dist <= 8 then meta:set_int("dist", dist) end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
local function get_objects_with_square_radius(pos, rad)
|
|
||||||
rad = rad + .5;
|
|
||||||
local objs = {}
|
|
||||||
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, math.sqrt(3)*rad)) do
|
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
|
||||||
local opos = object:getpos()
|
|
||||||
if pos.x - rad <= opos.x and opos.x <= pos.x + rad and pos.y - rad <= opos.y and opos.y <= pos.y + rad and pos.z - rad <= opos.z and opos.z <= pos.z + rad then
|
|
||||||
objs[#objs + 1] = object
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return objs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({nodenames={"group:mese_sand_tube"},interval=1,chance=1,
|
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}}
|
||||||
action=function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
for _,object in ipairs(get_objects_with_square_radius(pos, minetest.env:get_meta(pos):get_int("dist"))) do
|
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
if enable_detector_tube then
|
||||||
if object:get_luaentity().itemstring ~= "" then
|
|
||||||
local titem=tube_item(pos,object:get_luaentity().itemstring)
|
detector_plain_textures={"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png",
|
||||||
titem:get_luaentity().start_pos = {x=pos.x,y=pos.y-1,z=pos.z}
|
"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png"}
|
||||||
titem:setvelocity({x=0.01,y=1,z=-0.01})
|
detector_inv_texture="pipeworks_detector_tube_inv.png"
|
||||||
titem:setacceleration({x=0, y=0, z=0})
|
|
||||||
|
register_tube("pipeworks:detector_tube_on","Detector tube segment on (you hacker you)",detector_plain_textures,noctr_textures,
|
||||||
|
end_textures,short_texture,detector_inv_texture,
|
||||||
|
{tube={can_go=function(pos,node,velocity,stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
local nitems=meta:get_int("nitems")+1
|
||||||
|
meta:set_int("nitems", nitems)
|
||||||
|
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
|
||||||
|
return notvel(meseadjlist,velocity)
|
||||||
|
end},
|
||||||
|
groups={mesecon=2,not_in_creative_inventory=1},
|
||||||
|
drop="pipeworks:detector_tube_off_000000",
|
||||||
|
mesecons={receptor={state="on",
|
||||||
|
rules=mesecons_rules}},
|
||||||
|
item_exit = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local nitems=meta:get_int("nitems")-1
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
if nitems==0 then
|
||||||
|
minetest.set_node(pos,{name=string.gsub(name,"on","off")})
|
||||||
|
mesecon:receptor_off(pos,mesecons_rules)
|
||||||
|
else
|
||||||
|
meta:set_int("nitems", nitems)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("nitems", 1)
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
|
||||||
|
end})
|
||||||
|
|
||||||
|
register_tube("pipeworks:detector_tube_off","Detector tube segment",detector_plain_textures,noctr_textures,
|
||||||
|
end_textures,short_texture,detector_inv_texture,
|
||||||
|
{tube={can_go=function(pos,node,velocity,stack)
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
minetest.set_node(pos,{name=string.gsub(name,"off","on")})
|
||||||
|
mesecon:receptor_on(pos,mesecons_rules)
|
||||||
|
return notvel(meseadjlist,velocity)
|
||||||
|
end},
|
||||||
|
groups={mesecon=2},
|
||||||
|
mesecons={receptor={state="off",
|
||||||
|
rules=mesecons_rules}}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if enable_conductor_tube then
|
||||||
|
|
||||||
|
conductor_plain_textures={"pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png",
|
||||||
|
"pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png","pipeworks_conductor_tube_plain.png"}
|
||||||
|
conductor_noctr_textures={"pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png",
|
||||||
|
"pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png","pipeworks_conductor_tube_noctr.png"}
|
||||||
|
conductor_end_textures={"pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png",
|
||||||
|
"pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png","pipeworks_conductor_tube_end.png"}
|
||||||
|
conductor_short_texture="pipeworks_conductor_tube_short.png"
|
||||||
|
conductor_inv_texture="pipeworks_conductor_tube_inv.png"
|
||||||
|
|
||||||
|
conductor_on_plain_textures={"pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png",
|
||||||
|
"pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png","pipeworks_conductor_tube_on_plain.png"}
|
||||||
|
conductor_on_noctr_textures={"pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png",
|
||||||
|
"pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png","pipeworks_conductor_tube_on_noctr.png"}
|
||||||
|
conductor_on_end_textures={"pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png",
|
||||||
|
"pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png","pipeworks_conductor_tube_on_end.png"}
|
||||||
|
|
||||||
|
register_tube("pipeworks:conductor_tube_off","Conductor tube segment",conductor_plain_textures,conductor_noctr_textures,
|
||||||
|
conductor_end_textures,conductor_short_texture,conductor_inv_texture,
|
||||||
|
{groups={mesecon=2},
|
||||||
|
mesecons={conductor={state="off",
|
||||||
|
rules=mesecons_rules,
|
||||||
|
onstate="pipeworks:conductor_tube_on_#id"}}
|
||||||
|
})
|
||||||
|
|
||||||
|
register_tube("pipeworks:conductor_tube_on","Conductor tube segment on (you hacker you)",conductor_on_plain_textures,conductor_on_noctr_textures,
|
||||||
|
conductor_on_end_textures,conductor_short_texture,conductor_inv_texture,
|
||||||
|
{groups={mesecon=2,not_in_creative_inventory=1},
|
||||||
|
drop="pipeworks:conductor_tube_off_000000",
|
||||||
|
mesecons={conductor={state="on",
|
||||||
|
rules=mesecons_rules,
|
||||||
|
offstate="pipeworks:conductor_tube_off_#id"}}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if enable_accelerator_tube then
|
||||||
|
|
||||||
|
accelerator_noctr_textures={"pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png",
|
||||||
|
"pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png","pipeworks_accelerator_tube_noctr.png"}
|
||||||
|
accelerator_plain_textures={"pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png",
|
||||||
|
"pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png","pipeworks_accelerator_tube_plain.png"}
|
||||||
|
accelerator_end_textures={"pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png",
|
||||||
|
"pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png","pipeworks_accelerator_tube_end.png"}
|
||||||
|
accelerator_short_texture="pipeworks_accelerator_tube_short.png"
|
||||||
|
accelerator_inv_texture="pipeworks_accelerator_tube_inv.png"
|
||||||
|
|
||||||
|
register_tube("pipeworks:accelerator_tube","Accelerator pneumatic tube segment",accelerator_plain_textures,
|
||||||
|
accelerator_noctr_textures,accelerator_end_textures,accelerator_short_texture,accelerator_inv_texture,
|
||||||
|
{tube={can_go=function(pos,node,velocity,stack)
|
||||||
|
velocity.speed=velocity.speed+1
|
||||||
|
return notvel(meseadjlist,velocity)
|
||||||
|
end}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if enable_crossing_tube then
|
||||||
|
register_tube("pipeworks:crossing_tube","Crossing tube segment",accelerator_plain_textures,
|
||||||
|
accelerator_noctr_textures,accelerator_end_textures,accelerator_short_texture,accelerator_inv_texture,
|
||||||
|
{tube={can_go=function(pos,node,velocity,stack)
|
||||||
|
return velocity
|
||||||
|
end}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if enable_sand_tube then
|
||||||
|
|
||||||
|
sand_noctr_textures={"pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png",
|
||||||
|
"pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png","pipeworks_sand_tube_noctr.png"}
|
||||||
|
sand_plain_textures={"pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png",
|
||||||
|
"pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png","pipeworks_sand_tube_plain.png"}
|
||||||
|
sand_end_textures={"pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png",
|
||||||
|
"pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png","pipeworks_sand_tube_end.png"}
|
||||||
|
sand_short_texture="pipeworks_sand_tube_short.png"
|
||||||
|
sand_inv_texture="pipeworks_sand_tube_inv.png"
|
||||||
|
|
||||||
|
register_tube("pipeworks:sand_tube","Sand pneumatic tube segment",sand_plain_textures,sand_noctr_textures,sand_end_textures,
|
||||||
|
sand_short_texture,sand_inv_texture,
|
||||||
|
{groups={sand_tube=1}})
|
||||||
|
|
||||||
|
minetest.register_abm({nodenames={"group:sand_tube"},interval=1,chance=1,
|
||||||
|
action=function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
|
||||||
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
|
local titem=tube_item(pos,object:get_luaentity().itemstring)
|
||||||
|
titem:get_luaentity().start_pos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||||
|
titem:setvelocity({x=0.01,y=1,z=-0.01})
|
||||||
|
titem:setacceleration({x=0, y=0, z=0})
|
||||||
|
end
|
||||||
|
object:get_luaentity().itemstring = ""
|
||||||
|
object:remove()
|
||||||
end
|
end
|
||||||
object:get_luaentity().itemstring = ""
|
|
||||||
object:remove()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
})
|
end
|
||||||
|
|
||||||
|
if enable_mese_sand_tube then
|
||||||
|
|
||||||
|
mese_sand_noctr_textures={"pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png",
|
||||||
|
"pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png"}
|
||||||
|
mese_sand_plain_textures={"pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png",
|
||||||
|
"pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png"}
|
||||||
|
mese_sand_end_textures={"pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png",
|
||||||
|
"pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png"}
|
||||||
|
mese_sand_short_texture="pipeworks_mese_sand_tube_short.png"
|
||||||
|
mese_sand_inv_texture="pipeworks_mese_sand_tube_inv.png"
|
||||||
|
|
||||||
|
register_tube("pipeworks:mese_sand_tube","Mese sand pneumatic tube segment",mese_sand_plain_textures,mese_sand_noctr_textures,mese_sand_end_textures,
|
||||||
|
mese_sand_short_texture,mese_sand_inv_texture,
|
||||||
|
{groups={mese_sand_tube=1},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
meta:set_int("dist", 0)
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"size[2,1]"..
|
||||||
|
"field[.5,.5;1.5,1;dist;distance;${dist}]")
|
||||||
|
meta:set_string("infotext", "Mese sand pneumatic tube")
|
||||||
|
end,
|
||||||
|
on_receive_fields=function(pos,formname,fields,sender)
|
||||||
|
local meta=minetest.env:get_meta(pos)
|
||||||
|
local dist
|
||||||
|
_, dist = pcall(tonumber, fields.dist)
|
||||||
|
if dist and 0 <= dist and dist <= 8 then meta:set_int("dist", dist) end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local function get_objects_with_square_radius(pos, rad)
|
||||||
|
rad = rad + .5;
|
||||||
|
local objs = {}
|
||||||
|
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, math.sqrt(3)*rad)) do
|
||||||
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
|
local opos = object:getpos()
|
||||||
|
if pos.x - rad <= opos.x and opos.x <= pos.x + rad and pos.y - rad <= opos.y and opos.y <= pos.y + rad and pos.z - rad <= opos.z and opos.z <= pos.z + rad then
|
||||||
|
objs[#objs + 1] = object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return objs
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_abm({nodenames={"group:mese_sand_tube"},interval=1,chance=1,
|
||||||
|
action=function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
for _,object in ipairs(get_objects_with_square_radius(pos, minetest.env:get_meta(pos):get_int("dist"))) do
|
||||||
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
|
if object:get_luaentity().itemstring ~= "" then
|
||||||
|
local titem=tube_item(pos,object:get_luaentity().itemstring)
|
||||||
|
titem:get_luaentity().start_pos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||||
|
titem:setvelocity({x=0.01,y=1,z=-0.01})
|
||||||
|
titem:setacceleration({x=0, y=0, z=0})
|
||||||
|
end
|
||||||
|
object:get_luaentity().itemstring = ""
|
||||||
|
object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user