stuff needs to be globally-visible. Also, fix a bad drop on valve.
return (inv:is_empty("src") and inv:is_empty("recipe") and inv:is_empty("dst"))
end,
after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
autocrafterCache[minetest.hash_node_position(pos)] = nil
end
})
-- autorouting for pipes
-function pipe_scanforobjects(pos)
- pipe_autoroute({ x=pos.x-1, y=pos.y , z=pos.z }, "_loaded")
- pipe_autoroute({ x=pos.x+1, y=pos.y , z=pos.z }, "_loaded")
- pipe_autoroute({ x=pos.x , y=pos.y-1, z=pos.z }, "_loaded")
- pipe_autoroute({ x=pos.x , y=pos.y+1, z=pos.z }, "_loaded")
- pipe_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 }, "_loaded")
- pipe_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 }, "_loaded")
- pipe_autoroute(pos, "_loaded")
-
- pipe_autoroute({ x=pos.x-1, y=pos.y , z=pos.z }, "_empty")
- pipe_autoroute({ x=pos.x+1, y=pos.y , z=pos.z }, "_empty")
- pipe_autoroute({ x=pos.x , y=pos.y-1, z=pos.z }, "_empty")
- pipe_autoroute({ x=pos.x , y=pos.y+1, z=pos.z }, "_empty")
- pipe_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 }, "_empty")
- pipe_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 }, "_empty")
- pipe_autoroute(pos, "_empty")
-end
-
-function pipe_autoroute(pos, state)
- nctr = minetest.get_node(pos)
+local function autoroute_pipes(pos, state)
+ local nctr = minetest.get_node(pos)
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
- pipes_scansurroundings(pos)
+ local nsurround = pipeworks.scan_pipe_surroundings(pos)
- nsurround = pxm..pxp..pym..pyp..pzm..pzp
if nsurround == "000000" then nsurround = "110000" end
minetest.add_node(pos, { name = "pipeworks:pipe_"..nsurround..state })
end
+function pipeworks.scan_for_pipe_objects(pos)
+ autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z }, "_loaded")
+ autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z }, "_loaded")
+ autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z }, "_loaded")
+ autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z }, "_loaded")
+ autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 }, "_loaded")
+ autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 }, "_loaded")
+ autoroute_pipes(pos, "_loaded")
+
+ autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z }, "_empty")
+ autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z }, "_empty")
+ autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z }, "_empty")
+ autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z }, "_empty")
+ autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 }, "_empty")
+ autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 }, "_empty")
+ autoroute_pipes(pos, "_empty")
+end
+
-- auto-rotation code for various devices the tubes attach to
-function pipes_scansurroundings(pos)
- pxm=0
- pxp=0
- pym=0
- pyp=0
- pzm=0
- pzp=0
-
- nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
- nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
- nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
- nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
- nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
- nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
+function pipeworks.scan_pipe_surroundings(pos)
+ local pxm=0
+ local pxp=0
+ local pym=0
+ local pyp=0
+ local pzm=0
+ local pzp=0
+
+ local nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
+ local nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
+ local nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
+ local nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
+ local nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
+ local nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
if (string.find(nxm.name, "pipeworks:pipe_") ~= nil) then pxm=1 end
if (string.find(nxp.name, "pipeworks:pipe_") ~= nil) then pxp=1 end
-- end
--
+ return pxm..pxp..pym..pyp..pzm..pzp
end
-function pipe_look_for_stackable_tanks(pos)
+function pipeworks.look_for_stackable_tanks(pos)
local tym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
if string.find(tym.name, "pipeworks:storage_tank_") ~= nil or
-- autorouting for pneumatic tubes
-function tube_scanforobjects(pos)
+function pipeworks.scan_for_tube_objects(pos)
if pos == nil then return end
tube_autoroute({ x=pos.x-1, y=pos.y , z=pos.z })
tube_autoroute({ x=pos.x+1, y=pos.y , z=pos.z })
if minetest.registered_items[newnode.name]
and minetest.registered_items[newnode.name].tube
and minetest.registered_items[newnode.name].tube.connect_sides then
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
end)
if minetest.registered_items[oldnode.name]
and minetest.registered_items[oldnode.name].tube
and minetest.registered_items[oldnode.name].tube.connect_sides then
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
end)
return node2
end
-furnace=pipeworks:clone_node("default:furnace")
+local furnace=pipeworks:clone_node("default:furnace")
furnace.tiles[2] = "default_furnace_bottom.png^pipeworks_tube_connection_stony.png"
furnace.tiles[3] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
furnace.tiles[4] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
input_inventory="dst",
connect_sides={left=1, right=1, back=1, bottom=1}}
furnace.after_place_node= function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
furnace.after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
minetest.register_node(":default:furnace",furnace)
-furnace=pipeworks:clone_node("default:furnace_active")
+local furnace=pipeworks:clone_node("default:furnace_active")
furnace.tiles[2] = "default_furnace_bottom.png^pipeworks_tube_connection_stony.png"
furnace.tiles[3] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
furnace.tiles[4] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
input_inventory="dst",
connect_sides={left=1, right=1, back=1, bottom=1}}
furnace.after_place_node= function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
furnace.after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
minetest.register_node(":default:furnace_active",furnace)
-chest=pipeworks:clone_node("default:chest")
+local chest=pipeworks:clone_node("default:chest")
chest.tiles[1] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
chest.tiles[2] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
chest.tiles[3] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
input_inventory="main",
connect_sides={left=1, right=1, back=1, bottom=1, top=1}}
chest.after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
chest.after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
minetest.register_node(":default:chest",chest)
-chest_locked=pipeworks:clone_node("default:chest_locked")
+local chest_locked=pipeworks:clone_node("default:chest_locked")
chest_locked.tiles[1] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
chest_locked.tiles[2] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
chest_locked.tiles[3] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
connect_sides={left=1, right=1, back=1, bottom=1, top=1}}
local old_after_place = minetest.registered_nodes["default:chest_locked"].after_place_node;
chest_locked.after_place_node = function(pos, placer)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
old_after_place(pos, placer)
end
chest_locked.after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end
minetest.register_node(":default:chest_locked",chest_locked)
-- 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
-enable_one_way_tube = true
-CYCLIC = true
+local enable_pipes = true
+local enable_autocrafter = true
+local enable_deployer = true
+local enable_node_breaker = true
+local enable_teleport_tube = true
+local enable_pipe_devices = true
+local enable_redefines = true
+local enable_mese_tube = true
+local enable_detector_tube = true
+local enable_conductor_tube = true
+local enable_accelerator_tube = true
+local enable_crossing_tube = true
+local enable_sand_tube = true
+local enable_mese_sand_tube = true
+local enable_one_way_tube = true
+local CYCLIC = true
}
})
-function hacky_swap_node(pos,name)
+local function hacky_swap_node(pos,name)
local node=minetest.get_node(pos)
local meta=minetest.get_meta(pos)
local meta0=meta:to_table()
return (function() return x end)
end
-deployer_on = function(pos, node)
+local deployer_on = function(pos, node)
if node.name ~= "pipeworks:deployer_off" then
return
end
end
end
-deployer_off = function(pos, node)
+local deployer_off = function(pos, node)
if node.name == "pipeworks:deployer_on" then
hacky_swap_node(pos,"pipeworks:deployer_off")
nodeupdate(pos)
return inv:is_empty("main")
end,
after_place_node = function (pos, placer)
- tube_scanforobjects(pos, placer)
+ pipeworks.scan_for_tube_objects(pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
- after_dig_node = tube_scanforobjects,
+ after_dig_node = pipeworks.scan_for_tube_objects,
})
minetest.register_node("pipeworks:deployer_on", {
return inv:is_empty("main")
end,
after_place_node = function (pos, placer)
- tube_scanforobjects(pos, placer)
+ pipeworks.scan_for_tube_objects(pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
- after_dig_node = tube_scanforobjects,
+ after_dig_node = pipeworks.scan_for_tube_objects,
})
-- List of devices that should participate in the autoplace algorithm
+local pipereceptor_on = nil
+local pipereceptor_off = nil
+
if mesecon then
pipereceptor_on = {
receptor = {
}
end
-pipes_devicelist = {
+local pipes_devicelist = {
"pump",
"valve",
"storage_tank_0",
-- tables
-pipe_pumpbody = {
+local pipe_pumpbody = {
{ -7/16, -6/16, -7/16, 7/16, 5/16, 7/16 },
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }
}
-pipe_valvebody = {
+local pipe_valvebody = {
{ -4/16, -4/16, -4/16, 4/16, 4/16, 4/16 }
}
-pipe_valvehandle_on = {
+local pipe_valvehandle_on = {
{ -5/16, 4/16, -1/16, 0, 5/16, 1/16 }
}
-pipe_valvehandle_off = {
+local pipe_valvehandle_off = {
{ -1/16, 4/16, -5/16, 1/16, 5/16, 0 }
}
-pipe_sensorbody = {
+local pipe_sensorbody = {
{ -3/16, -2/16, -2/16, 3/16, 2/16, 2/16 }
}
-spigot_bottomstub = {
+local spigot_bottomstub = {
{ -2/64, -16/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
{ -4/64, -16/64, -5/64, 4/64, 1/64, 5/64 },
{ -5/64, -16/64, -4/64, 5/64, 1/64, 4/64 },
{ -8/64, -16/64, -3/64, 8/64, -14/64, 3/64 }
}
-spigot_stream = {
+local spigot_stream = {
{ -3/64, (-41/64)-0.01, -5/64, 3/64, -16/64, 5/64 },
{ -4/64, (-41/64)-0.01, -4/64, 4/64, -16/64, 4/64 },
{ -5/64, (-41/64)-0.01, -3/64, 5/64, -16/64, 3/64 }
}
-entry_panel = {
+local entry_panel = {
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
}
-
-
-fountainhead_model = {
+local fountainhead_model = {
{ -2/64, -32/64, -6/64, 2/64, 21/64, 6/64 }, -- main segment
{ -4/64, -32/64, -5/64, 4/64, 21/64, 5/64 },
{ -5/64, -32/64, -4/64, 5/64, 21/64, 4/64 },
end
local pumpboxes = {}
- pipeworks_add_pipebox(pumpboxes, pipe_pumpbody)
- pipeworks_add_pipebox(pumpboxes, pipe_topstub)
+ pipeworks.add_pipebox(pumpboxes, pipe_pumpbody)
+ pipeworks.add_pipebox(pumpboxes, pipe_topstub)
minetest.register_node("pipeworks:pump_"..states[s], {
description = "Pump/Intake Module",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
drop = "pipeworks:pump_off",
mesecons = {effector = {
})
local valveboxes = {}
- pipeworks_add_pipebox(valveboxes, pipe_leftstub)
- pipeworks_add_pipebox(valveboxes, pipe_valvebody)
+ pipeworks.add_pipebox(valveboxes, pipe_leftstub)
+ pipeworks.add_pipebox(valveboxes, pipe_valvebody)
if states[s] == "off" then
- pipeworks_add_pipebox(valveboxes, pipe_valvehandle_off)
+ pipeworks.add_pipebox(valveboxes, pipe_valvehandle_off)
else
- pipeworks_add_pipebox(valveboxes, pipe_valvehandle_on)
+ pipeworks.add_pipebox(valveboxes, pipe_valvehandle_on)
end
- pipeworks_add_pipebox(valveboxes, pipe_rightstub)
+ pipeworks.add_pipebox(valveboxes, pipe_rightstub)
local tilex = "pipeworks_valvebody_ends.png"
local tilez = "pipeworks_valvebody_sides.png"
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
- drop = "pipeworks:valve_off",
+ drop = "pipeworks:valve_off_empty",
mesecons = {effector = {
action_on = function (pos, node)
minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
end
local valveboxes = {}
-pipeworks_add_pipebox(valveboxes, pipe_leftstub)
-pipeworks_add_pipebox(valveboxes, pipe_valvebody)
-pipeworks_add_pipebox(valveboxes, pipe_rightstub)
-pipeworks_add_pipebox(valveboxes, pipe_valvehandle_on)
+pipeworks.add_pipebox(valveboxes, pipe_leftstub)
+pipeworks.add_pipebox(valveboxes, pipe_valvebody)
+pipeworks.add_pipebox(valveboxes, pipe_rightstub)
+pipeworks.add_pipebox(valveboxes, pipe_valvehandle_on)
minetest.register_node("pipeworks:valve_on_loaded", {
description = "Valve",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
drop = "pipeworks:valve_off_empty",
mesecons = {effector = {
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
})
-- outlet spigot
local spigotboxes = {}
- pipeworks_add_pipebox(spigotboxes, pipe_backstub)
- pipeworks_add_pipebox(spigotboxes, spigot_bottomstub)
- pipeworks_add_pipebox(spigotboxes, pipe_bendsphere)
+ pipeworks.add_pipebox(spigotboxes, pipe_backstub)
+ pipeworks.add_pipebox(spigotboxes, spigot_bottomstub)
+ pipeworks.add_pipebox(spigotboxes, pipe_bendsphere)
local spigotboxes_pouring = {}
- pipeworks_add_pipebox(spigotboxes_pouring, spigot_stream)
- pipeworks_add_pipebox(spigotboxes_pouring, pipe_backstub)
- pipeworks_add_pipebox(spigotboxes_pouring, spigot_bottomstub)
- pipeworks_add_pipebox(spigotboxes_pouring, pipe_bendsphere)
+ pipeworks.add_pipebox(spigotboxes_pouring, spigot_stream)
+ pipeworks.add_pipebox(spigotboxes_pouring, pipe_backstub)
+ pipeworks.add_pipebox(spigotboxes_pouring, spigot_bottomstub)
+ pipeworks.add_pipebox(spigotboxes_pouring, pipe_bendsphere)
minetest.register_node("pipeworks:spigot", {
description = "Spigot outlet",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
node_box = {
type = "fixed",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
node_box = {
type = "fixed",
-- wall, for use in places where walls should look like they're airtight)
local airtightboxes = {}
-pipeworks_add_pipebox(airtightboxes, pipe_frontstub)
-pipeworks_add_pipebox(airtightboxes, pipe_backstub)
-pipeworks_add_pipebox(airtightboxes, entry_panel)
+pipeworks.add_pipebox(airtightboxes, pipe_frontstub)
+pipeworks.add_pipebox(airtightboxes, pipe_backstub)
+pipeworks.add_pipebox(airtightboxes, entry_panel)
minetest.register_node("pipeworks:entry_panel_empty", {
description = "Airtight Pipe entry/exit",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
node_box = {
type = "fixed",
}
},
on_place = function(itemstack, placer, pointed_thing)
- if not pipeworks_node_is_owned(pointed_thing.under, placer)
- and not pipeworks_node_is_owned(pointed_thing.above, placer) then
+ if not pipeworks.node_is_owned(pointed_thing.under, placer)
+ and not pipeworks.node_is_owned(pointed_thing.above, placer) then
local node = minetest.get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name]
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
minetest.add_node(pos1, {name = "pipeworks:entry_panel_empty", param2 = fdir })
- pipe_scanforobjects(pos1)
+ pipeworks.scan_for_pipe_objects(pos1)
if not pipeworks_expect_infinite_stacks then
itemstack:take_item()
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
node_box = {
type = "fixed",
})
local sensorboxes = {}
-pipeworks_add_pipebox(sensorboxes, pipe_leftstub)
-pipeworks_add_pipebox(sensorboxes, pipe_sensorbody)
-pipeworks_add_pipebox(sensorboxes, pipe_rightstub)
+pipeworks.add_pipebox(sensorboxes, pipe_leftstub)
+pipeworks.add_pipebox(sensorboxes, pipe_sensorbody)
+pipeworks.add_pipebox(sensorboxes, pipe_rightstub)
minetest.register_node("pipeworks:flow_sensor_empty", {
description = "Flow Sensor",
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
on_construct = function(pos)
if mesecon then
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
on_construct = function(pos)
if mesecon then
-- tanks
for fill = 0, 10 do
- if fill == 0 then
- filldesc="empty"
- sgroups = {snappy=3, pipe=1, tankfill=fill+1}
- image = nil
- else
+ local filldesc="empty"
+ local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
+ local image = nil
+
+ if fill ~= 0 then
filldesc=fill.."0% full"
sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
image = "pipeworks_storage_tank_fittings.png"
drop = "pipeworks:storage_tank_"..fill,
after_place_node = function(pos)
pipe_look_for_stackable_tanks(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
})
walkable = true,
after_place_node = function(pos)
pipe_look_for_stackable_tanks(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
})
end
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
on_construct = function(pos)
if mesecon then
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
on_construct = function(pos)
if mesecon then
local finitewater = minetest.setting_getbool("liquid_finite")
-pipeworks_check_for_liquids = function(pos)
+pipeworks.check_for_liquids = function(pos)
local coords = {
{x=pos.x,y=pos.y-1,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
return false
end
-pipeworks_check_for_inflows = function(pos,node)
+pipeworks.check_for_inflows = function(pos,node)
local coords = {
{x=pos.x,y=pos.y-1,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
for i =1,6 do
if newnode then break end
local name = minetest.get_node(coords[i]).name
- if name and (name == "pipeworks:pump_on" and pipeworks_check_for_liquids(coords[i])) or string.find(name,"_loaded") then
+ if name and (name == "pipeworks:pump_on" and pipeworks.check_for_liquids(coords[i])) or string.find(name,"_loaded") then
if string.find(name,"_loaded") then
local source = minetest.get_meta(coords[i]):get_string("source")
if source == minetest.pos_to_string(pos) then break end
end
end
-pipeworks_check_sources = function(pos,node)
+pipeworks.check_sources = function(pos,node)
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
if not sourcepos then return end
local source = minetest.get_node(sourcepos).name
local newnode = false
- if source and not ((source == "pipeworks:pump_on" and pipeworks_check_for_liquids(sourcepos)) or string.find(source,"_loaded") or source == "ignore" ) then
+ if source and 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")
end
end
end
-pipeworks_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
if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then
local spigotname = minetest.get_node(pos).name
end
end
-pipeworks_fountainhead_check = function(pos, node)
+pipeworks.fountainhead_check = function(pos, node)
local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
if abovename and (abovename == "air" or abovename == "default:water_flowing" or abovename == "default:water_source") then
local fountainhead_name = minetest.get_node(pos).name
dofile(pipeworks.worldpath.."/pipeworks_settings.txt")
end
--- Helper functions
-
+pipeworks.expect_infinite_stacks = true
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
pipeworks_expect_infinite_stacks = false
-else
- pipeworks_expect_infinite_stacks = true
end
-function pipeworks_fix_image_names(table, replacement)
- outtable={}
+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}}
+
+-- Helper functions
+
+function pipeworks.fix_image_names(table, replacement)
+ local outtable={}
for i in ipairs(table) do
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
end
return outtable
end
-function pipeworks_add_pipebox(t, b)
+function pipeworks.add_pipebox(t, b)
for i in ipairs(b)
do table.insert(t, b[i])
end
end
-function pipeworks_node_is_owned(pos, placer)
+function pipeworks.node_is_owned(pos, placer)
local ownername = false
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
if HasOwner(pos, placer) then -- returns true if the node is owned
end
end
-function pipeworks_replace_name(tbl,tr,name)
+function pipeworks.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]=pipeworks_replace_name(i,tr,name)
+ ntbl[key]=pipeworks.replace_name(i,tr,name)
else
ntbl[key]=i
end
dofile(pipeworks.modpath.."/tubes.lua")
-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},
+local 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}}
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
print("Pipeworks loaded!")
+
return inv:is_empty("main")
end,
after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
mesecons={effector={action_on=function(pos,node)
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
return inv:is_empty("main")
end,
after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
mesecons={effector={action_on=function(pos,node)
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
adjlist={{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}}
function notvel(tbl,vel)
- tbl2={}
+ local tbl2={}
for _,val in ipairs(tbl) do
if val.x~=-vel.x or val.y~=-vel.y or val.z~=-vel.z then table.insert(tbl2,val) end
end
}
})
-function hacky_swap_node(pos,name)
+local function hacky_swap_node(pos,name)
local node=minetest.get_node(pos)
local meta=minetest.get_meta(pos)
local meta0=meta:to_table()
end
end
-node_breaker_on = function(pos, node)
- if node.name == "pipeworks:nodebreaker_off" then
- hacky_swap_node(pos,"pipeworks:nodebreaker_on")
- break_node(pos,node.param2)
- nodeupdate(pos)
- end
-end
-
-node_breaker_off = function(pos, node)
- if node.name == "pipeworks:nodebreaker_on" then
- hacky_swap_node(pos,"pipeworks:nodebreaker_off")
- nodeupdate(pos)
- end
-end
-
local function delay(x)
return (function() return x end)
end
-function break_node (pos, facedir)
+local function break_node (pos, facedir)
--locate the outgoing velocity, front, and back of the node via facedir_to_dir
if type(facedir) ~= "number" or facedir < 0 or facedir > 23 then return end
end
end
+local node_breaker_on = function(pos, node)
+ if node.name == "pipeworks:nodebreaker_off" then
+ hacky_swap_node(pos,"pipeworks:nodebreaker_on")
+ break_node(pos,node.param2)
+ nodeupdate(pos)
+ end
+end
+
+local node_breaker_off = function(pos, node)
+ if node.name == "pipeworks:nodebreaker_on" then
+ hacky_swap_node(pos,"pipeworks:nodebreaker_off")
+ nodeupdate(pos)
+ end
+end
+
minetest.register_node("pipeworks:nodebreaker_off", {
description = "Node Breaker",
tile_images = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
end,
after_place_node = function (pos, placer)
- tube_scanforobjects(pos, placer)
+ pipeworks.scan_for_tube_objects(pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
- after_dig_node = tube_scanforobjects,
+ after_dig_node = pipeworks.scan_for_tube_objects,
})
minetest.register_node("pipeworks:nodebreaker_on", {
inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
end,
after_place_node = function (pos, placer)
- tube_scanforobjects(pos, placer)
+ pipeworks.scan_for_tube_objects(pos, placer)
local placer_pos = placer:getpos()
--correct for the player's height
minetest.log("action", "real (6d) facedir: " .. node.param2)
end
end,
- after_dig_node = tube_scanforobjects,
+ after_dig_node = pipeworks.scan_for_tube_objects,
})
local outimgs = {}
if yp==1 then
- pipeworks_add_pipebox(outboxes, pipe_topstub)
+ 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)
+ 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)
+ 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)
+ 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)
+ 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)
+ pipeworks.add_pipebox(outboxes, pipe_frontstub)
table.insert(outsel, pipe_selectboxes[5])
table.insert(outimgs, "pipeworks_pipe_end.png")
else
end
if jx+jy+jz >= 2 then
- pipeworks_add_pipebox(outboxes, pipe_bendsphere)
+ pipeworks.add_pipebox(outboxes, pipe_bendsphere)
end
if (jx==2 and jy~=2 and jz~=2) then
minetest.register_node("pipeworks:pipe_"..pname.."_empty", {
description = pipedesc,
drawtype = "nodebox",
- tiles = pipeworks_fix_image_names(outimgs, "_empty"),
+ tiles = pipeworks.fix_image_names(outimgs, "_empty"),
inventory_image = image,
sunlight_propagates=true,
paramtype = "light",
walkable = true,
drop = "pipeworks:pipe_110000_empty",
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(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"),
+ tiles = pipeworks.fix_image_names(outimgs, "_loaded"),
inventory_image = image,
sunlight_propagates = true,
paramtype = "light",
walkable = true,
drop = "pipeworks:pipe_110000_empty",
after_place_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end,
after_dig_node = function(pos)
- pipe_scanforobjects(pos)
+ pipeworks.scan_for_pipe_objects(pos)
end
})
table.insert(pipes_empty_nodenames,"pipeworks:pipe_"..pname.."_empty") -- for the abms
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks_check_for_inflows(pos,node)
+ pipeworks.check_for_inflows(pos,node)
end
})
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks_check_sources(pos,node)
+ pipeworks.check_sources(pos,node)
end
})
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks_spigot_check(pos,node)
+ pipeworks.spigot_check(pos,node)
end
})
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks_fountainhead_check(pos,node)
+ pipeworks.fountainhead_check(pos,node)
end
})
-filename=minetest.get_worldpath() .. "/teleport_tubes"
+local filename=minetest.get_worldpath() .. "/teleport_tubes"
-function read_file()
+local function read_file()
local f = io.open(filename, "r")
if f==nil then return {} end
local t = f:read("*all")
return minetest.deserialize(t)
end
-function write_file(tbl)
+local function write_file(tbl)
local f = io.open(filename, "w")
f:write(minetest.serialize(tbl))
f:close()
end
-function add_tube_in_file(pos,channel, cr)
- tbl=read_file()
+local function add_tube_in_file(pos,channel, cr)
+ local tbl=read_file()
for _,val in ipairs(tbl) do
if val.x==pos.x and val.y==pos.y and val.z==pos.z then
return
write_file(tbl)
end
-function remove_tube_in_file(pos)
- tbl=read_file()
- newtbl={}
+local function remove_tube_in_file(pos)
+ local tbl=read_file()
+ local newtbl={}
for _,val in ipairs(tbl) do
if val.x~=pos.x or val.y~=pos.y or val.z~=pos.z then
table.insert(newtbl,val)
write_file(newtbl)
end
-function get_tubes_in_file(pos,channel)
- tbl=read_file()
- newtbl={}
- changed=false
+local function get_tubes_in_file(pos,channel)
+ local tbl=read_file()
+ local newtbl={}
+ local changed=false
for _,val in ipairs(tbl) do
local node = minetest.get_node(val)
local meta = minetest.get_meta(val)
return newtbl
end
-teleport_noctr_textures={"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png",
+local teleport_noctr_textures={"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png",
"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png"}
-teleport_plain_textures={"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png",
+local teleport_plain_textures={"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png",
"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png"}
-teleport_end_textures={"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png",
+local teleport_end_textures={"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png",
"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png"}
-teleport_short_texture="pipeworks_teleport_tube_short.png"
-teleport_inv_texture="pipeworks_teleport_tube_inv.png"
+local teleport_short_texture="pipeworks_teleport_tube_short.png"
+local teleport_inv_texture="pipeworks_teleport_tube_inv.png"
register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",teleport_plain_textures,
teleport_noctr_textures,teleport_end_textures,teleport_short_texture,teleport_inv_texture,
pos.x=target[d].x
pos.y=target[d].y
pos.z=target[d].z
- return meseadjlist
+ return pipeworks.meseadjlist
end},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
-tube_leftstub = {
+local tube_leftstub = {
{ -32/64, -9/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -X face
}
-tube_rightstub = {
+local tube_rightstub = {
{ -9/64, -9/64, -9/64, 32/64, 9/64, 9/64 }, -- tube segment against +X face
}
-tube_bottomstub = {
+local tube_bottomstub = {
{ -9/64, -32/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -Y face
}
-tube_topstub = {
+local tube_topstub = {
{ -9/64, -9/64, -9/64, 9/64, 32/64, 9/64 }, -- tube segment against +Y face
}
-tube_frontstub = {
+local tube_frontstub = {
{ -9/64, -9/64, -32/64, 9/64, 9/64, 9/64 }, -- tube segment against -Z face
}
-tube_backstub = {
+local tube_backstub = {
{ -9/64, -9/64, -9/64, 9/64, 9/64, 32/64 }, -- tube segment against -Z face
}
-tube_selectboxes = {
+local tube_selectboxes = {
{ -32/64, -10/64, -10/64, 10/64, 10/64, 10/64 },
{ -10/64 , -10/64, -10/64, 32/64, 10/64, 10/64 },
{ -10/64 , -32/64, -10/64, 10/64, 10/64, 10/64 },
-- Functions
-function tube_addbox(t, b)
+local function tube_addbox(t, b)
for i in ipairs(b)
do table.insert(t, b[i])
end
end
--- now define the nodes!
-function register_tube(name,desc,plain_textures,noctr_textures,end_textures,short_texture,inv_texture,special)
+-- now, a function to define the tubes
+
+register_tube = function(name, desc, plain, noctrs, ends, short, inv, special)
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
if yp==1 then
tube_addbox(outboxes, tube_topstub)
table.insert(outsel, tube_selectboxes[4])
- table.insert(outimgs, noctr_textures[4])
+ table.insert(outimgs, noctrs[4])
else
- table.insert(outimgs, plain_textures[4])
+ table.insert(outimgs, plain[4])
end
if ym==1 then
tube_addbox(outboxes, tube_bottomstub)
table.insert(outsel, tube_selectboxes[3])
- table.insert(outimgs, noctr_textures[3])
+ table.insert(outimgs, noctrs[3])
else
- table.insert(outimgs, plain_textures[3])
+ table.insert(outimgs, plain[3])
end
if xp==1 then
tube_addbox(outboxes, tube_rightstub)
table.insert(outsel, tube_selectboxes[2])
- table.insert(outimgs, noctr_textures[2])
+ table.insert(outimgs, noctrs[2])
else
- table.insert(outimgs, plain_textures[2])
+ table.insert(outimgs, plain[2])
end
if xm==1 then
tube_addbox(outboxes, tube_leftstub)
table.insert(outsel, tube_selectboxes[1])
- table.insert(outimgs, noctr_textures[1])
+ table.insert(outimgs, noctrs[1])
else
- table.insert(outimgs, plain_textures[1])
+ table.insert(outimgs, plain[1])
end
if zp==1 then
tube_addbox(outboxes, tube_backstub)
table.insert(outsel, tube_selectboxes[6])
- table.insert(outimgs, noctr_textures[6])
+ table.insert(outimgs, noctrs[6])
else
- table.insert(outimgs, plain_textures[6])
+ table.insert(outimgs, plain[6])
end
if zm==1 then
tube_addbox(outboxes, tube_frontstub)
table.insert(outsel, tube_selectboxes[5])
- table.insert(outimgs, noctr_textures[5])
+ table.insert(outimgs, noctrs[5])
else
- table.insert(outimgs, plain_textures[5])
+ table.insert(outimgs, plain[5])
end
local jx = xp+xm
if (jx+jy+jz) == 1 then
if xm == 1 then
table.remove(outimgs, 3)
- table.insert(outimgs, 3, end_textures[3])
+ table.insert(outimgs, 3, ends[3])
end
if xp == 1 then
table.remove(outimgs, 4)
- table.insert(outimgs, 4, end_textures[4])
+ table.insert(outimgs, 4, ends[4])
end
if ym == 1 then
table.remove(outimgs, 1)
- table.insert(outimgs, 1, end_textures[1])
+ table.insert(outimgs, 1, ends[1])
end
if xp == 1 then
table.remove(outimgs, 2)
- table.insert(outimgs, 2, end_textures[2])
+ table.insert(outimgs, 2, ends[2])
end
if zm == 1 then
table.remove(outimgs, 5)
- table.insert(outimgs, 5, end_textures[5])
+ table.insert(outimgs, 5, ends[5])
end
if zp == 1 then
table.remove(outimgs, 6)
- table.insert(outimgs, 6, end_textures[6])
+ table.insert(outimgs, 6, ends[6])
end
end
local tname = xm..xp..ym..yp..zm..zp
- local tgroups = ""
- if tname ~= "000000" then
- tgroups = {snappy=3, tube=1, not_in_creative_inventory=1}
- tubedesc = desc.." ("..tname..")... You hacker, you."
- iimg=plain_textures[1]
- wscale = {x=1,y=1,z=1}
- else
+ local tgroups = {snappy=3, tube=1, not_in_creative_inventory=1}
+ local tubedesc = desc.." ("..tname..")... You hacker, you."
+ local iimg=plain[1]
+ local wscale = {x=1,y=1,z=1}
+
+ if tname == "000000" then
tgroups = {snappy=3, tube=1}
tubedesc = desc
- iimg=inv_texture
+ iimg=inv
outimgs = {
- short_texture,short_texture,
- end_textures[3],end_textures[4],
- short_texture,short_texture
+ short,short,
+ ends[3],ends[4],
+ short,short
}
outboxes = { -24/64, -9/64, -9/64, 24/64, 9/64, 9/64 }
outsel = { -24/64, -10/64, -10/64, 24/64, 10/64, 10/64 }
table.insert(tubenodes,name.."_"..tname)
- nodedef={
+ local nodedef={
description = tubedesc,
drawtype = "nodebox",
tiles = outimgs,
+ sunlight_propagates = true,
inventory_image=iimg,
wield_image=iimg,
wield_scale=wscale,
end
end,
after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[name.."_"..tname].after_place_node_ then
minetest.registered_nodes[name.."_"..tname].after_place_node_(pos)
end
end,
after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[name.."_"..tname].after_dig_node_ then
minetest.registered_nodes[name.."_"..tname].after_dig_node_(pos)
end
nodedef.tube[key]=val
end
elseif type(value)=="table" then
- nodedef[key]=pipeworks_replace_name(value,"#id",tname)
+ nodedef[key]=pipeworks.replace_name(value,"#id",tname)
elseif type(value)=="string" then
nodedef[key]=string.gsub(value,"#id",tname)
else
end
end
+-- now let's actually call that function to get the real work done!
-noctr_textures={"pipeworks_tube_noctr.png","pipeworks_tube_noctr.png","pipeworks_tube_noctr.png",
+local 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"}
-plain_textures={"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png",
+local plain_textures={"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png",
"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png"}
-end_textures={"pipeworks_tube_end.png","pipeworks_tube_end.png","pipeworks_tube_end.png",
+local end_textures={"pipeworks_tube_end.png","pipeworks_tube_end.png","pipeworks_tube_end.png",
"pipeworks_tube_end.png","pipeworks_tube_end.png","pipeworks_tube_end.png"}
-short_texture="pipeworks_tube_short.png"
-inv_texture="pipeworks_tube_inv.png"
+local short_texture="pipeworks_tube_short.png"
+local inv_texture="pipeworks_tube_inv.png"
register_tube("pipeworks:tube","Pneumatic tube segment",plain_textures,noctr_textures,end_textures,short_texture,inv_texture)
-if enable_mese_tube then
-
- 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"
- 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}}
+local 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"}
+local 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"}
+local 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"}
+local mese_short_texture="pipeworks_mese_tube_short.png"
+local mese_inv_texture="pipeworks_mese_tube_inv.png"
+if enable_mese_tube then
register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_textures,mese_noctr_textures,
mese_end_textures,mese_short_texture,mese_inv_texture,
{tube={can_go=function(pos,node,velocity,stack)
local inv=meta:get_inventory()
local found=false
local name=stack:get_name()
- for i,vect in ipairs(meseadjlist) do
+ for i,vect in ipairs(pipeworks.meseadjlist) do
if meta:get_int("l"..tostring(i).."s")==1 then
for _,st in ipairs(inv:get_list("line"..tostring(i))) do
if st:get_name()==name then
end
end
if found==false then
- for i,vect in ipairs(meseadjlist) do
+ for i,vect in ipairs(pipeworks.meseadjlist) do
if meta:get_int("l"..tostring(i).."s")==1 then
if inv:is_empty("line"..tostring(i)) then
table.insert(tbl,vect)
})
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}}
+ local 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}}
if enable_detector_tube then
- detector_plain_textures={"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png",
+ local detector_plain_textures={"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png",
"pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png","pipeworks_detector_tube_plain.png"}
- detector_inv_texture="pipeworks_detector_tube_inv.png"
+ local detector_inv_texture="pipeworks_detector_tube_inv.png"
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,
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)
+ return notvel(pipeworks.meseadjlist,velocity)
end},
groups={mesecon=2,not_in_creative_inventory=1},
drop="pipeworks:detector_tube_off_000000",
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)
+ return notvel(pipeworks.meseadjlist,velocity)
end},
groups={mesecon=2},
mesecons={receptor={state="off",
})
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"}
+local 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"}
+local 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"}
+local 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"}
+local conductor_short_texture="pipeworks_conductor_tube_short.png"
+local conductor_inv_texture="pipeworks_conductor_tube_inv.png"
+
+local 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"}
+local 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"}
+local 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"}
+if enable_conductor_tube then
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},
})
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"
+local 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"}
+local 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"}
+local 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"}
+local accelerator_short_texture="pipeworks_accelerator_tube_short.png"
+local accelerator_inv_texture="pipeworks_accelerator_tube_inv.png"
+if enable_accelerator_tube then
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)
+ return notvel(pipeworks.meseadjlist,velocity)
end}
})
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"
+local 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"}
+local 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"}
+local 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"}
+local sand_short_texture="pipeworks_sand_tube_short.png"
+local sand_inv_texture="pipeworks_sand_tube_inv.png"
+if enable_sand_tube then
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}})
})
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"
+local 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"}
+local 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"}
+local 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"}
+local mese_sand_short_texture="pipeworks_mese_sand_tube_short.png"
+local mese_sand_inv_texture="pipeworks_mese_sand_tube_inv.png"
+if enable_mese_sand_tube then
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},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
after_dig_node = function(pos)
- tube_scanforobjects(pos)
+ pipeworks.scan_for_tube_objects(pos)
end,
tube={connect_sides={left=1, right=1},
can_go=function(pos,node,velocity,stack)