1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-06-29 14:50:41 +02:00

3 Commits

28 changed files with 349 additions and 938 deletions

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
local craft_time = 1
@ -17,7 +16,7 @@ end
local function get_item_info(stack)
local name = stack:get_name()
local def = minetest.registered_items[name]
local description = def and def.description or S("Unknown item")
local description = def and def.description or "Unknown item"
return description, name
end
@ -67,9 +66,12 @@ local function run_autocrafter(pos, elapsed)
local inventory = meta:get_inventory()
local craft = get_craft(pos, inventory)
local output_item = craft.output.item
-- NALC: existence de limitgroup ?
local limitcraft = minetest.get_item_group(output_item:get_name(), "limitcraft") or 0
-- only use crafts that have an actual result
if output_item:is_empty() then
meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
-- NALC: ou si l'item n'est pas dans le group limitcraft
if output_item:is_empty() or limitcraft > 0 then
meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe")
return false
end
@ -102,7 +104,7 @@ local function after_recipe_change(pos, inventory)
if inventory:is_empty("recipe") then
minetest.get_node_timer(pos):stop()
autocrafterCache[minetest.hash_node_position(pos)] = nil
meta:set_string("infotext", S("unconfigured Autocrafter"))
meta:set_string("infotext", "unconfigured Autocrafter")
inventory:set_stack("output", 1, "")
return
end
@ -127,7 +129,7 @@ local function after_recipe_change(pos, inventory)
craft = craft or get_craft(pos, inventory, hash)
local output_item = craft.output.item
local description, name = get_item_info(output_item)
meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name))
meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name))
inventory:set_stack("output", 1, output_item)
after_inventory_change(pos)
@ -191,8 +193,8 @@ local function update_meta(meta, enabled)
"listring[context;dst]" ..
"listring[current_player;main]"
if minetest.get_modpath("digilines") then
fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]"
fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]"
fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]"
fs = fs.."button_exit[5,3.2;2,1;save;Save]"
end
meta:set_string("formspec",fs)
@ -201,13 +203,13 @@ local function update_meta(meta, enabled)
-- this might be more written code, but actually executes less
local output = meta:get_inventory():get_stack("output", 1)
if output:is_empty() then -- doesn't matter if paused or not
meta:set_string("infotext", S("unconfigured Autocrafter"))
meta:set_string("infotext", "unconfigured Autocrafter")
return false
end
local description, name = get_item_info(output)
local infotext = enabled and S("'@1' Autocrafter (@2)", description, name)
or S("paused '@1' Autocrafter", description)
local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name)
or string.format("paused '%s' Autocrafter", description)
meta:set_string("infotext", infotext)
return enabled
@ -227,7 +229,7 @@ local function upgrade_autocrafter(pos, meta)
update_meta(meta, true)
if meta:get_string("virtual_items") == "1" then -- we are version 2
-- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
-- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
meta:set_string("virtual_items", "")
else -- we are version 1
local recipe = inv:get_list("recipe")
@ -249,7 +251,7 @@ local function upgrade_autocrafter(pos, meta)
end
minetest.register_node("pipeworks:autocrafter", {
description = S("Autocrafter"),
description = "Autocrafter",
drawtype = "normal",
tiles = {"pipeworks_autocrafter.png"},
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1},
@ -389,27 +391,6 @@ minetest.register_node("pipeworks:autocrafter", {
end
end
after_recipe_change(pos,inv)
elseif msg == "get_recipe" then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local recipe = {}
for y=0,2,1 do
local row = {}
for x=1,3,1 do
local slot = y*3+x
table.insert(row, inv:get_stack("recipe",slot):get_name())
end
table.insert(recipe, row)
end
local setchan = meta:get_string("channel")
local output = inv:get_stack("output", 1)
digiline:receptor_send(pos, digiline.rules.default, setchan, {
recipe = recipe,
result = {
name = output:get_name(),
count = output:get_count(),
}
})
elseif msg == "off" then
update_meta(meta, false)
minetest.get_node_timer(pos):stop()

View File

@ -53,28 +53,27 @@ local function tube_autoroute(pos)
}
-- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6
local adjlist = {} -- this will be used in item_transport
local positions = {}
local nodes = {}
for i, adj in ipairs(adjustments) do
local position = vector.add(pos, adj)
local node = minetest.get_node(position)
positions[i] = vector.add(pos, adj)
nodes[i] = minetest.get_node(positions[i])
end
for i, node in ipairs(nodes) do
local idef = minetest.registered_nodes[node.name]
-- handle the tubes themselves
if is_tube(node.name) then
active[i] = 1
table.insert(adjlist, adj)
-- handle new style connectors
elseif idef and idef.tube and idef.tube.connect_sides then
if idef.tube.connect_sides[nodeside(node, vector.multiply(adj, -1))] then
local dir = adjustments[i]
if idef.tube.connect_sides[nodeside(node, vector.multiply(dir, -1))] then
active[i] = 1
table.insert(adjlist, adj)
end
end
end
minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist))
-- all sides checked, now figure which tube to use.
local nodedef = minetest.registered_nodes[nctr.name]

View File

@ -86,9 +86,10 @@ function pipeworks.table_contains(tbl, element)
end
function pipeworks.table_extend(tbl, tbl2)
local oldlength = #tbl
for i = 1,#tbl2 do
tbl[oldlength + i] = tbl2[i]
local index = #tbl + 1
for _, elt in ipairs(tbl2) do
tbl[index] = elt
index = index + 1
end
end

View File

@ -77,8 +77,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
pipeworks.after_place(pos)
end)
minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
elseif pipeworks.may_configure(pos, player) then
-- Pipeworks Switch
end
-- Pipeworks Switch
if pipeworks.may_configure(pos, player) and not fields.quit then
fs_helpers.on_receive_fields(pos, fields)
minetest.show_formspec(player:get_player_name(), "pipeworks:chest_formspec", get_chest_formspec(pos))
end

View File

@ -1,10 +1,7 @@
-- this file is basically a modified copy of
-- minetest_game/mods/default/furnaces.lua
-- translation support
local S = minetest.get_translator("pipeworks")
local DS = minetest.get_translator("default")
local fs_helpers = pipeworks.fs_helpers
tube_entry = "^pipeworks_tube_connection_stony.png"
@ -39,7 +36,7 @@ local function active_formspec(fuel_percent, item_percent, pos, meta)
pipeworks.button_off,
pipeworks.button_on
}
).."label[0.9,3.51;"..S("Allow splitting incoming material (not fuel) stacks from tubes").."]"
).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
return formspec
end
@ -70,7 +67,7 @@ local function inactive_formspec(pos, meta)
pipeworks.button_off,
pipeworks.button_on
}
).."label[0.9,3.51;"..S("Allow splitting incoming material (not fuel) stacks from tubes").."]"
).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
return formspec
end
@ -93,7 +90,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if listname == "fuel" then
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext", DS("Furnace is empty"))
meta:set_string("infotext", "Furnace is empty")
end
return stack:get_count()
else
@ -222,40 +219,40 @@ local function furnace_node_timer(pos, elapsed)
if cookable then
item_percent = math.floor(src_time / cooked.time * 100)
if item_percent > 100 then
item_state = DS("100% (output full)")
item_state = "100% (output full)"
else
item_state = DS("@1%", item_percent)
item_state = item_percent .. "%"
end
else
if srclist[1]:is_empty() then
item_state = DS("Empty")
item_state = "Empty"
else
item_state = DS("Not cookable")
item_state = "Not cookable"
end
end
local fuel_state = DS("Empty")
local active = DS("Furnace inactive")
local fuel_state = "Empty"
local active = "inactive "
local result = false
if fuel_totaltime ~= 0 then
active = DS("Furnace active")
active = "active "
local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
fuel_state = DS("@1%", fuel_percent)
fuel_state = fuel_percent .. "%"
formspec = active_formspec(fuel_percent, item_percent, pos, meta)
swap_node(pos, "default:furnace_active")
-- make sure timer restarts automatically
result = true
else
if not fuellist[1]:is_empty() then
fuel_state = DS("@1%", "0")
fuel_state = "0%"
end
swap_node(pos, "default:furnace")
-- stop timer on the inactive furnace
minetest.get_node_timer(pos):stop()
end
local infotext = active.." "..DS("(Item: @1; Fuel: @2)", item_state, fuel_state)
local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
--
-- Set meta values
@ -274,7 +271,7 @@ end
--
minetest.register_node(":default:furnace", {
description = DS("Furnace"),
description = "Furnace",
tiles = {
"default_furnace_top.png"..tube_entry,
"default_furnace_bottom.png"..tube_entry,
@ -363,7 +360,7 @@ minetest.register_node(":default:furnace", {
})
minetest.register_node(":default:furnace_active", {
description = DS("Furnace"),
description = "Furnace",
tiles = {
"default_furnace_top.png"..tube_entry,
"default_furnace_bottom.png"..tube_entry,

View File

@ -1,9 +1,7 @@
local S = minetest.get_translator("pipeworks")
local straight = function(pos, node, velocity, stack) return {velocity} end
minetest.register_node("pipeworks:steel_block_embedded_tube", {
description = S("Airtight steelblock embedded tube"),
description = "Airtight steelblock embedded tube",
tiles = {
"default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png",
@ -47,7 +45,7 @@ local pane_box = {
}
minetest.register_node("pipeworks:steel_pane_embedded_tube", {
drawtype = "nodebox",
description = S("Airtight panel embedded tube"),
description = "Airtight panel embedded tube ",
tiles = {
"pipeworks_pane_embedded_tube_sides.png^[transformR90",
"pipeworks_pane_embedded_tube_sides.png^[transformR90",

7
depends.txt Normal file
View File

@ -0,0 +1,7 @@
default
basic_materials
screwdriver
mesecons?
mesecons_mvps?
digilines?
signs_lib?

1
description.txt Normal file
View File

@ -0,0 +1 @@
This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local new_flow_logic_register = pipeworks.flowables.register
local polys = ""
@ -136,7 +135,7 @@ for s in ipairs(states) do
local pumpname = "pipeworks:pump_"..states[s]
minetest.register_node(pumpname, {
description = S("Pump/Intake Module"),
description = "Pump/Intake Module",
drawtype = "mesh",
mesh = "pipeworks_pump"..polys..".obj",
tiles = { "pipeworks_pump_"..states[s]..".png" },
@ -179,7 +178,7 @@ for s in ipairs(states) do
local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
minetest.register_node(nodename_valve_empty, {
description = S("Valve"),
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_"..states[s]..polys..".obj",
tiles = { "pipeworks_valve.png" },
@ -225,7 +224,7 @@ end
local nodename_valve_loaded = "pipeworks:valve_on_loaded"
minetest.register_node(nodename_valve_loaded, {
description = S("Valve"),
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_on"..polys..".obj",
tiles = { "pipeworks_valve.png" },
@ -273,7 +272,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_valve_loaded, true
-- FIXME: should this do anything useful in the new flow logic?
minetest.register_node("pipeworks:grating", {
description = S("Decorative grating"),
description = "Decorative grating",
tiles = {
"pipeworks_grating_top.png",
"pipeworks_grating_sides.png",
@ -306,7 +305,7 @@ minetest.register_node("pipeworks:grating", {
local nodename_spigot_empty = "pipeworks:spigot"
minetest.register_node(nodename_spigot_empty, {
description = S("Spigot outlet"),
description = "Spigot outlet",
drawtype = "mesh",
mesh = "pipeworks_spigot"..polys..".obj",
tiles = { "pipeworks_spigot.png" },
@ -337,7 +336,7 @@ minetest.register_node(nodename_spigot_empty, {
local nodename_spigot_loaded = "pipeworks:spigot_pouring"
minetest.register_node(nodename_spigot_loaded, {
description = S("Spigot outlet"),
description = "Spigot outlet",
drawtype = "mesh",
mesh = "pipeworks_spigot_pouring"..polys..".obj",
tiles = {
@ -403,7 +402,7 @@ local panel_cbox = {
local nodename_panel_empty = "pipeworks:entry_panel_empty"
minetest.register_node(nodename_panel_empty, {
description = S("Airtight Pipe entry/exit"),
description = "Airtight Pipe entry/exit",
drawtype = "mesh",
mesh = "pipeworks_entry_panel"..polys..".obj",
tiles = { "pipeworks_entry_panel.png" },
@ -423,7 +422,7 @@ minetest.register_node(nodename_panel_empty, {
local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
minetest.register_node(nodename_panel_loaded, {
description = S("Airtight Pipe entry/exit"),
description = "Airtight Pipe entry/exit",
drawtype = "mesh",
mesh = "pipeworks_entry_panel"..polys..".obj",
tiles = { "pipeworks_entry_panel.png" },
@ -449,7 +448,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true
local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
minetest.register_node(nodename_sensor_empty, {
description = S("Flow Sensor"),
description = "Flow Sensor",
drawtype = "mesh",
mesh = "pipeworks_flow_sensor"..polys..".obj",
tiles = { "pipeworks_flow_sensor_off.png" },
@ -488,7 +487,7 @@ minetest.register_node(nodename_sensor_empty, {
local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
minetest.register_node(nodename_sensor_loaded, {
description = S("Flow sensor (on)"),
description = "Flow sensor (on)",
drawtype = "mesh",
mesh = "pipeworks_flow_sensor"..polys..".obj",
tiles = { "pipeworks_flow_sensor_on.png" },
@ -537,18 +536,18 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi
-- TODO flow-logic-stub: these don't currently do anything under the new flow logic.
for fill = 0, 10 do
local filldesc=S("empty")
local filldesc="empty"
local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
local image = nil
if fill ~= 0 then
filldesc=S("@1% full", 10*fill)
filldesc=fill.."0% full"
sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
image = "pipeworks_storage_tank_fittings.png"
end
minetest.register_node("pipeworks:expansion_tank_"..fill, {
description = S("Expansion Tank (@1)", filldesc),
description = "Expansion Tank ("..filldesc..")... You hacker, you.",
tiles = {
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_fittings.png",
@ -576,7 +575,7 @@ for fill = 0, 10 do
})
minetest.register_node("pipeworks:storage_tank_"..fill, {
description = S("Fluid Storage Tank (@1)", filldesc),
description = "Fluid Storage Tank ("..filldesc..")",
tiles = {
"pipeworks_storage_tank_fittings.png",
"pipeworks_storage_tank_fittings.png",
@ -608,7 +607,7 @@ end
local nodename_fountain_empty = "pipeworks:fountainhead"
minetest.register_node(nodename_fountain_empty, {
description = S("Fountainhead"),
description = "Fountainhead",
drawtype = "mesh",
mesh = "pipeworks_fountainhead"..polys..".obj",
tiles = { "pipeworks_fountainhead.png" },
@ -642,7 +641,7 @@ minetest.register_node(nodename_fountain_empty, {
local nodename_fountain_loaded = "pipeworks:fountainhead_pouring"
minetest.register_node(nodename_fountain_loaded, {
description = S("Fountainhead"),
description = "Fountainhead",
drawtype = "mesh",
mesh = "pipeworks_fountainhead"..polys..".obj",
tiles = { "pipeworks_fountainhead.png" },
@ -692,7 +691,7 @@ local sp_cbox = {
local nodename_sp_empty = "pipeworks:straight_pipe_empty"
minetest.register_node(nodename_sp_empty, {
description = S("Straight-only Pipe"),
description = "Straight-only Pipe",
drawtype = "mesh",
mesh = "pipeworks_straight_pipe"..polys..".obj",
tiles = { "pipeworks_straight_pipe_empty.png" },
@ -714,7 +713,7 @@ minetest.register_node(nodename_sp_empty, {
local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
minetest.register_node(nodename_sp_loaded, {
description = S("Straight-only Pipe"),
description = "Straight-only Pipe",
drawtype = "mesh",
mesh = "pipeworks_straight_pipe"..polys..".obj",
tiles = { "pipeworks_straight_pipe_loaded.png" },

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local fs_helpers = pipeworks.fs_helpers
local function delay(x)
@ -6,47 +5,47 @@ local function delay(x)
end
local function set_filter_infotext(data, meta)
local infotext = S("@1 Filter-Injector", data.wise_desc)
local infotext = data.wise_desc.." Filter-Injector"
if meta:get_int("slotseq_mode") == 2 then
infotext = infotext .. " "..S("(slot #@1 next)", meta:get_int("slotseq_index"))
infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
end
meta:set_string("infotext", infotext)
end
local function set_filter_formspec(data, meta)
local itemname = S("@1 Filter-Injector", data.wise_desc)
local itemname = data.wise_desc.." Filter-Injector"
local formspec
if data.digiline then
formspec = "size[8,2.7]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"field[0.3,1.5;8.0,1;channel;"..S("Channel")..";${channel}]"..
"field[0.3,1.5;8.0,1;channel;Channel;${channel}]"..
fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode",
{S("Sequence slots by Priority"),
S("Sequence slots Randomly"),
S("Sequence slots by Rotation")})..
{"Sequence slots by Priority",
"Sequence slots Randomly",
"Sequence slots by Rotation"})..
fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode",
{S("Exact match - off"),
S("Exact match - on")})
{"Exact match - off",
"Exact match - on "})
else
local exmatch_button = ""
if data.stackwise then
exmatch_button =
fs_helpers.cycling_button(meta, "button[4,3.5;4,1", "exmatch_mode",
{S("Exact match - off"),
S("Exact match - on")})
{"Exact match - off",
"Exact match - on "})
end
formspec = "size[8,8.5]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"label[0,1;"..S("Prefer item types:").."]"..
"label[0,1;Prefer item types:]"..
"list[context;main;0,1.5;8,2;]"..
fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode",
{S("Sequence slots by Priority"),
S("Sequence slots Randomly"),
S("Sequence slots by Rotation")})..
{"Sequence slots by Priority",
"Sequence slots Randomly",
"Sequence slots by Rotation"})..
exmatch_button..
"list[current_player;main;0,4.5;8,4;]" ..
"listring[]"
@ -54,6 +53,116 @@ local function set_filter_formspec(data, meta)
meta:set_string("formspec", formspec)
end
-- todo SOON: this function has *way too many* parameters
local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all,digiline)
local sposes = {}
if not frominvname or not frominv:get_list(frominvname) then return end
for spos,stack in ipairs(frominv:get_list(frominvname)) do
local matches
if filterfor == "" then
matches = stack:get_name() ~= ""
else
local fname = filterfor.name
local fgroup = filterfor.group
local fwear = filterfor.wear
local fmetadata = filterfor.metadata
matches = (not fname -- If there's a name filter,
or stack:get_name() == fname) -- it must match.
and (not fgroup -- If there's a group filter,
or (type(fgroup) == "string" -- it must be a string
and minetest.get_item_group( -- and it must match.
stack:get_name(), fgroup) ~= 0))
and (not fwear -- If there's a wear filter:
or (type(fwear) == "number" -- If it's a number,
and stack:get_wear() == fwear) -- it must match.
or (type(fwear) == "table" -- If it's a table:
and (not fwear[1] -- If there's a lower bound,
or (type(fwear[1]) == "number" -- it must be a number
and fwear[1] <= stack:get_wear())) -- and it must be <= the actual wear.
and (not fwear[2] -- If there's an upper bound
or (type(fwear[2]) == "number" -- it must be a number
and stack:get_wear() < fwear[2])))) -- and it must be > the actual wear.
-- If the wear filter is of any other type, fail.
--
and (not fmetadata -- If there's a matadata filter,
or (type(fmetadata) == "string" -- it must be a string
and stack:get_metadata() == fmetadata)) -- and it must match.
end
if matches then table.insert(sposes, spos) end
end
if #sposes == 0 then return false end
if slotseq_mode == 1 then
for i = #sposes, 2, -1 do
local j = math.random(i)
local t = sposes[j]
sposes[j] = sposes[i]
sposes[i] = t
end
elseif slotseq_mode == 2 then
local headpos = filtmeta:get_int("slotseq_index")
table.sort(sposes, function (a, b)
if a >= headpos then
if b < headpos then return true end
else
if b >= headpos then return false end
end
return a < b
end)
end
for _, spos in ipairs(sposes) do
local stack = frominv:get_stack(frominvname, spos)
local doRemove = stack:get_count()
if fromtube.can_remove then
doRemove = fromtube.can_remove(frompos, fromnode, stack, dir, frominvname, spos)
elseif fromdef.allow_metadata_inventory_take then
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
end
-- stupid lack of continue statements grumble
if doRemove > 0 then
if slotseq_mode == 2 then
local nextpos = spos + 1
if nextpos > frominv:get_size(frominvname) then
nextpos = 1
end
filtmeta:set_int("slotseq_index", nextpos)
set_filter_infotext(data, filtmeta)
end
local item
local count
if all then
count = math.min(stack:get_count(), doRemove)
if filterfor.count and (filterfor.count > 1 or digiline) then
if exmatch_mode ~= 0 and filterfor.count > count then
return false -- not enough, fail
else
-- limit quantity to filter amount
count = math.min(filterfor.count, count)
end
end
else
count = 1
end
if fromtube.remove_items then
-- it could be the entire stack...
item = fromtube.remove_items(frompos, fromnode, stack, dir, count, frominvname, spos)
else
item = stack:take_item(count)
frominv:set_stack(frominvname, spos, stack)
if fromdef.on_metadata_inventory_take then
fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
end
end
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir)
local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name())
return true-- only fire one item, please
end
end
return false
end
local function punch_filter(data, filtpos, filtnode, msg)
local filtmeta = minetest.get_meta(filtpos)
local filtinv = filtmeta:get_inventory()
@ -69,6 +178,8 @@ local function punch_filter(data, filtpos, filtnode, msg)
if not fromdef then return end
local fromtube = fromdef.tube
local input_special_cases = {
["technic:mv_furnace"] = "dst",
["technic:mv_furnace_active"] = "dst",
["technic:mv_electric_furnace"] = "dst",
["technic:mv_electric_furnace_active"] = "dst",
["technic:mv_alloy_furnace"] = "dst",
@ -83,13 +194,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
["technic:mv_grinder_active"] = "dst",
["technic:tool_workshop"] = "src",
["technic:mv_freezer"] = "dst",
["technic:mv_freezer_active"] = "dst",
["technic:hv_electric_furnace"] = "dst",
["technic:hv_electric_furnace_active"] = "dst",
["technic:hv_compressor"] = "dst",
["technic:hv_compressor_active"] = "dst",
["technic:hv_grinder"] = "dst",
["technic:hv_grinder_active"] = "dst"
["technic:mv_freezer_active"] = "dst"
}
-- make sure there's something appropriate to inject the item into
@ -109,7 +214,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
if not (fromtube and fromtube.input_inventory) then return end
local slotseq_mode
local exmatch_mode
local exact_match
local filters = {}
if data.digiline then
@ -146,10 +251,10 @@ local function punch_filter(data, filtpos, filtnode, msg)
local exmatch = msg.exmatch
local t_exmatch = type(exmatch)
if t_exmatch == "number" and (exmatch == 0 or exmatch == 1) then
exmatch_mode = exmatch
if t_exmatch == "number" and exmatch >= 0 and exmatch <= 1 then
exact_match = exmatch
elseif t_exmatch == "boolean" then
exmatch_mode = exmatch and 1 or 0
exact_match = exmatch and 1 or 0
end
local slotseq_index = msg.slotseq_index
@ -166,11 +271,11 @@ local function punch_filter(data, filtpos, filtnode, msg)
filtmeta:set_int("slotseq_mode", slotseq_mode)
end
if exmatch_mode ~= nil then
filtmeta:set_int("exmatch_mode", exmatch_mode)
if exact_match ~= nil then
filtmeta:set_int("exmatch_mode", exact_match)
end
if slotseq_mode ~= nil or exmatch_mode ~= nil then
if slotseq_mode ~= nil or exact_match ~= nil then
set_filter_formspec(data, filtmeta)
end
@ -208,8 +313,8 @@ local function punch_filter(data, filtpos, filtnode, msg)
slotseq_mode = filtmeta:get_int("slotseq_mode")
end
if exmatch_mode == nil then
exmatch_mode = filtmeta:get_int("exmatch_mode")
if exact_match == nil then
exact_match = filtmeta:get_int("exmatch_mode")
end
local frominv
@ -223,120 +328,10 @@ local function punch_filter(data, filtpos, filtnode, msg)
frominv = frommeta:get_inventory()
end
if fromtube.before_filter then fromtube.before_filter(frompos) end
local function grabAndFire(frominvname, filterfor)
local sposes = {}
if not frominvname or not frominv:get_list(frominvname) then return end
for spos,stack in ipairs(frominv:get_list(frominvname)) do
local matches
if filterfor == "" then
matches = stack:get_name() ~= ""
else
local fname = filterfor.name
local fgroup = filterfor.group
local fwear = filterfor.wear
local fmetadata = filterfor.metadata
matches = (not fname -- If there's a name filter,
or stack:get_name() == fname) -- it must match.
and (not fgroup -- If there's a group filter,
or (type(fgroup) == "string" -- it must be a string
and minetest.get_item_group( -- and it must match.
stack:get_name(), fgroup) ~= 0))
and (not fwear -- If there's a wear filter:
or (type(fwear) == "number" -- If it's a number,
and stack:get_wear() == fwear) -- it must match.
or (type(fwear) == "table" -- If it's a table:
and (not fwear[1] -- If there's a lower bound,
or (type(fwear[1]) == "number" -- it must be a number
and fwear[1] <= stack:get_wear())) -- and it must be <= the actual wear.
and (not fwear[2] -- If there's an upper bound
or (type(fwear[2]) == "number" -- it must be a number
and stack:get_wear() < fwear[2])))) -- and it must be > the actual wear.
-- If the wear filter is of any other type, fail.
and (not fmetadata -- If there's a metadata filter,
or (type(fmetadata) == "string" -- it must be a string
and stack:get_metadata() == fmetadata)) -- and it must match.
end
if matches then table.insert(sposes, spos) end
end
if #sposes == 0 then return false end
if slotseq_mode == 1 then
for i = #sposes, 2, -1 do
local j = math.random(i)
local t = sposes[j]
sposes[j] = sposes[i]
sposes[i] = t
end
elseif slotseq_mode == 2 then
local headpos = filtmeta:get_int("slotseq_index")
table.sort(sposes, function (a, b)
if a >= headpos then
if b < headpos then return true end
else
if b >= headpos then return false end
end
return a < b
end)
end
for _, spos in ipairs(sposes) do
local stack = frominv:get_stack(frominvname, spos)
local doRemove = stack:get_count()
if fromtube.can_remove then
doRemove = fromtube.can_remove(frompos, fromnode, stack, dir, frominvname, spos)
elseif fromdef.allow_metadata_inventory_take then
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
end
-- stupid lack of continue statements grumble
if doRemove > 0 then
if slotseq_mode == 2 then
local nextpos = spos + 1
if nextpos > frominv:get_size(frominvname) then
nextpos = 1
end
filtmeta:set_int("slotseq_index", nextpos)
set_filter_infotext(data, filtmeta)
end
local item
local count
if data.stackwise then
count = math.min(stack:get_count(), doRemove)
if filterfor.count and (filterfor.count > 1 or data.digiline) then
if exmatch_mode ~= 0 and filterfor.count > count then
return false -- not enough, fail
else
-- limit quantity to filter amount
count = math.min(filterfor.count, count)
end
end
else
count = 1
end
if fromtube.remove_items then
-- it could be the entire stack...
item = fromtube.remove_items(frompos, fromnode, stack, dir, count, frominvname, spos)
else
item = stack:take_item(count)
frominv:set_stack(frominvname, spos, stack)
if fromdef.on_metadata_inventory_take then
fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
end
end
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir)
local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name())
return true -- only fire one item, please
end
end
return false
end
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
local done = false
for _, filterfor in ipairs(filters) do
if grabAndFire(frominvname, filterfor) then
if grabAndFire(data, slotseq_mode, exact_match, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise, data.digiline) then
done = true
break
end
@ -349,23 +344,23 @@ end
for _, data in ipairs({
{
name = "filter",
wise_desc = S("Itemwise"),
wise_desc = "Itemwise",
stackwise = false,
},
{
name = "mese_filter",
wise_desc = S("Stackwise"),
wise_desc = "Stackwise",
stackwise = true,
},
{ -- register even if no digilines
name = "digiline_filter",
wise_desc = S("Digiline"),
wise_desc = "Digiline",
stackwise = true,
digiline = true,
},
}) do
local node = {
description = S("@1 Filter-Injector", data.wise_desc),
description = data.wise_desc.." Filter-Injector",
tiles = {
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_top.png",

View File

@ -10,7 +10,6 @@ local DEBUG = false
pipeworks.worldpath = minetest.get_worldpath()
pipeworks.modpath = minetest.get_modpath("pipeworks")
local S = minetest.get_translator("pipeworks")
dofile(pipeworks.modpath.."/default_settings.lua")
-- Read the external config file if it exists.
@ -46,7 +45,7 @@ pipeworks.liquid_texture = "default_water.png"
pipeworks.button_off = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
pipeworks.button_base = "image_button[0,4.3;1,0.6"
pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
pipeworks.button_label = "label[0.9,4.31;Allow splitting incoming stacks from tubes]"
-- Helper functions
@ -71,8 +70,8 @@ function pipeworks.may_configure(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and owner == name then -- wielders and filters
return true
if owner ~= "" then -- wielders and filters
return owner == name
end
return not minetest.is_protected(pos, name)
end
@ -150,4 +149,4 @@ end
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
minetest.log("info", "Pipeworks loaded!")
print("Pipeworks loaded!")

View File

@ -25,7 +25,7 @@ end
-- both optional w/ sensible defaults and fallback to normal allow_* function
-- XXX: possibly change insert_object to insert_item
local default_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}}
local 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 pipeworks.notvel(tbl, vel)
local tbl2={}
@ -61,7 +61,7 @@ local crunch_tube = function(pos, cnode, cmeta)
local itemcount = tube_item_count[h] or 0
if itemcount > max_tube_limit then
cmeta:set_string("the_tube_was", minetest.serialize(cnode))
pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
print("[Pipeworks] Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end
@ -80,9 +80,6 @@ local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
else
local adjlist_string = minetest.get_meta(pos):get_string("adjlist")
local adjlist = minetest.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
can_go = pipeworks.notvel(adjlist, vel)
end
-- can_go() is expected to return an array-like table of candidate offsets.

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
if not minetest.get_modpath("auto_tree_tap") and
minetest.get_modpath("technic") then
@ -21,7 +20,7 @@ if not minetest.get_modpath("auto_tree_tap") and
})
minetest.register_node(":auto_tree_tap:off", {
description = S("Auto-Tap"),
description = "Auto-Tap",
tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
is_ground_content = true,

View File

@ -1,112 +0,0 @@
# textdomain: pipeworks
# License: CC-by-SA 4.0
# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
## digilines interfacing
Channel=Canal
## init
Allow splitting incoming stacks from tubes=Séparer les piles venant des tubes
## autocrafter
Unknown item=Item inconnu
unconfigured Autocrafter: unknown recipe=Autocrafteur non-configuré : recette inconnue
unconfigured Autocrafter=Autocrafteur non-configuré
'@1' Autocrafter (@2)=Autocrafteur de '@1' (@2)
Save=Valider
paused '@1' Autocrafter=Autocrafteur de '@1' en pause
Autocrafter=Autocrafteur
## compat-furnaces
Allow splitting incoming material (not fuel) stacks from tubes=Séparer les piles (sauf le carburant) venant des tubes
## decorative tubes
Airtight steelblock embedded tube=Tube hermétique intégré à un bloc dacier
Airtight panel embedded tube=Tube hermétique intégré à un panneau
## devices
Pump/Intake Module=Module de pompage et dadmission
Valve=Vanne
Decorative grating=Grillage décoratif
Spigot outlet=Sortie de robinet
Airtight Pipe entry/exit=Extrémité de tube hermétique
Flow Sensor=Détecteur de débit
Flow sensor (on)=Détecteur de débit (actif)
empty=vide
@1% full=plein à @1 %
Expansion Tank (@1)=Réservoir dexpansion (@1)
Fluid Storage Tank (@1)=Réservoir de liquides (@1)
Fountainhead=Tête de fontaine
Straight-only Pipe=Tuyau droit
## filter-injector
(slot #@1 next)=(slot suivant : #@1)
@1 Filter-Injector=Filtre-injecteur @1
Sequence slots by Priority=Ordonner par priorité
Sequence slots Randomly=Ordonner aléatoirement
Sequence slots by Rotation=Ordonner en rotation
Exact match - off=Filtrage inactif
Exact match - on=Filtrage actif
Prefer item types:=Items à filtrer :
Itemwise=par item
Stackwise=par piles ditems
Digiline=digiline
## legacy
Auto-Tap=Robinet darbre automatique
## pipes
Pipe Segment=Segment de tuyau
Pipe Segment (legacy)=Segment de tuyau (obsolète)
## routing tubes
Pneumatic tube segment=Segment de tuyau pneumatique
Broken Tube=Tuyau cassé
High Priority Tube Segment=Segment de tuyau haute priorité
Accelerating Pneumatic Tube Segment=Segment de tuyau pneumatique accélérante
Crossing Pneumatic Tube Segment=Intersection de tuyau pneumatique
One way tube=Tuyau unidirectionnel
## signal tubes
Detecting Pneumatic Tube Segment on=Segment de tuyau pneumatique avec détecteur (actif)
Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur
Digiline Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur digiline
Digiline Detecting Tube=Tuyau avec détecteur digiline
Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur
Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur actif
Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur digiline
Mesecon and Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur mesecon et digiline
Mesecon and Digiline Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur mesecon et digiline (actif)
## sorting tubes
Sorting Pneumatic Tube Segment=Segment de tuyau pneumatique triant
Sorting pneumatic tube=Tuyau pneumatique triant
## teleport tube
Receive=Reception
channels are public by default=Les canaux sont publics par défaut
use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur
unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à lutilisateur @2.
Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2.
Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2'
## trashcan
Trash Can=Poubelle
## tube registration
Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
## vacuum tubes
Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant
Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m)
## wielder
Node Breaker=Casseur de blocs
Deployer=Poseur de blocs
Dispenser=Distributeur

View File

@ -1,110 +0,0 @@
# textdomain: pipeworks
# License: CC-by-SA 4.0
# Author: pevernow <3450354617@qq.com>
## digilines interfacing
Channel=频道
## init
Allow splitting incoming stacks from tubes=允许从管道中拆分传入堆栈
## autocrafter
Unknown item=通道
unconfigured Autocrafter: unknown recipe=未配置的自动工作台: 未知配方
unconfigured Autocrafter=未配置的自动工作台
'@1' Autocrafter (@2)=自动工作台 '@1' (@2)
Save=保存
paused '@1' Autocrafter=暂停的自动工作台
Autocrafter=自动工作台
## compat-furnaces
Allow splitting incoming material (not fuel) stacks from tubes=允许从管子中分离进来的材料(不是燃料)堆
## decorative tubes
Airtight steelblock embedded tube=密封嵌入式铁块管道
Airtight panel embedded tube=密封嵌入式片状管道
## devices
Pump/Intake Module=泵/进气模块
Valve=阀门
Decorative grating=Decorative grating
Spigot outlet=龙头
Airtight Pipe entry/exit=密闭管进/出
Flow Sensor=流量传感器
Flow sensor (on)=流量传感器(上)
empty=空的
@1% full=满的@1 %
Expansion Tank (@1)=扩展水箱 (@1)
Fluid Storage Tank (@1)=储液罐 (@1)
Fountainhead=源泉
Straight-only Pipe=直管
## filter-injector
(slot #@1 next)=(下一个插槽 : #@1)
@1 Filter-Injector=@1取物器
Sequence slots by Priority=优先顺序排列
Sequence slots Randomly=随机排列时隙
Sequence slots by Rotation=旋转顺序槽
Exact match - off=完全匹配-关闭
Exact match - on=完全匹配-开启
Prefer item types:=偏好物品类型 :
Itemwise=逐项
Stackwise=堆叠方式
Digiline=Digiline
## legacy
Auto-Tap=自动轴阀
## pipes
Pipe Segment=管道
Pipe Segment (legacy)=管道(旧版)
## routing tubes
Pneumatic tube segment=普通管道
Broken Tube=断管
High Priority Tube Segment=高优先级管段
Accelerating Pneumatic Tube Segment=加速管道
Crossing Pneumatic Tube Segment=定向管道
One way tube=单向管
## signal tubes
Detecting Pneumatic Tube Segment on=检测管道(运行中)
Detecting Pneumatic Tube Segment=检测管道
Digiline Detecting Pneumatic Tube Segment=Digiline检测管道
Digiline Detecting Tube=Digiline检测管
Conducting Pneumatic Tube Segment=传导管道
Conducting Pneumatic Tube Segment on=传导管道(运行中)
Digiline Conducting Pneumatic Tube Segment=Digiline传导式气动管道
Mesecon and Digiline Conducting Pneumatic Tube Segment=Mesecon和Digiline传导管道
Mesecon and Digiline Conducting Pneumatic Tube Segment on=Mesecon和Digiline传导管道运行中
## sorting tubes
Sorting Pneumatic Tube Segment=分类管道
Sorting pneumatic tube=分类管道
## teleport tube
Receive=接收
channels are public by default=频道默认为公开
use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Teleporting Pneumatic Tube Segment=传送管道
unconfigured Teleportation Tube=未配置的传送管道
Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1保留供@2专用
Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
## trashcan
Trash Can=垃圾箱
## tube registration
Pneumatic tube segment (legacy)=普通管道(旧式)
## vacuum tubes
Vacuuming Pneumatic Tube Segment=拾取管道
Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)
## wielder
Node Breaker=方块破坏器
Deployer=放置器
Dispenser=投掷器

View File

@ -1,112 +0,0 @@
# textdomain: pipeworks
# License: CC-by-SA 4.0
# Author:
## digilines interfacing
Channel=
## init
Allow splitting incoming stacks from tubes=
## autocrafter
Unknown item=
unconfigured Autocrafter: unknown recipe=
unconfigured Autocrafter=
'@1' Autocrafter (@2)=
Save=
paused '@1' Autocrafter=
Autocrafter=
## compat-furnaces
Allow splitting incoming material (not fuel) stacks from tubes=
## decorative tubes
Airtight steelblock embedded tube=
Airtight panel embedded tube=
## devices
Pump/Intake Module=
Valve=
Decorative grating=
Spigot outlet=
Airtight Pipe entry/exit=
Flow Sensor=
Flow sensor (on)=
empty=
@1% full=
Expansion Tank (@1)=
Fluid Storage Tank (@1)=
Fountainhead=
Straight-only Pipe=
## filter-injector
(slot #@1 next)=
@1 Filter-Injector=
Sequence slots by Priority=
Sequence slots Randomly=
Sequence slots by Rotation=
Exact match - off=
Exact match - on=
Prefer item types:=
Itemwise=
Stackwise=
Digiline=
## legacy
Auto-Tap=
## pipes
Pipe Segment=
Pipe Segment (legacy)=
## routing tubes
Pneumatic tube segment=
Broken Tube=
High Priority Tube Segment=
Accelerating Pneumatic Tube Segment=
Crossing Pneumatic Tube Segment=
One way tube=
## signal tubes
Detecting Pneumatic Tube Segment on=
Detecting Pneumatic Tube Segment=
Digiline Detecting Pneumatic Tube Segment=
Digiline Detecting Tube=
Conducting Pneumatic Tube Segment=
Conducting Pneumatic Tube Segment on=
Digiline Conducting Pneumatic Tube Segment=
Mesecon and Digiline Conducting Pneumatic Tube Segment=
Mesecon and Digiline Conducting Pneumatic Tube Segment on=
## sorting tubes
Sorting Pneumatic Tube Segment=
Sorting pneumatic tube=
## teleport tube
Receive=
channels are public by default=
use <player>:<channel> for fully private channels=
use <player>;<channel> for private receivers=
Teleporting Pneumatic Tube Segment=
unconfigured Teleportation Tube=
Sorry, channel '@1' is reserved for exclusive use by @2=
Sorry, receiving from channel '@1' is reserved for @2=
Teleportation Tube @1 on '@2'=
## trashcan
Trash Can=
## tube registration
Pneumatic tube segment (legacy)=
## vacuum tubes
Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=
## wielder
Node Breaker=
Deployer=
Dispenser=

View File

@ -13,10 +13,8 @@
-- newport = merge_port_states(state1, state2): just does result = state1 or state2 for every port
-- set_port(pos, rule, state): activates/deactivates the mesecons according to the port states
-- set_port_states(pos, ports): Applies new port states to a Luacontroller at pos
-- run_inner(pos, code, event): runs code on the controller at pos and event
-- reset_formspec(pos, code, errmsg): installs new code and prints error messages, without resetting LCID
-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error message
-- run(pos, event): a wrapper for run_inner which gets code & handles errors via reset_meta
-- run(pos): runs the code in the controller at pos
-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error messages
-- resetn(pos): performs a hardware reset, turns off all ports
--
-- The Sandbox
@ -26,7 +24,7 @@
-- use too much memory from the sandbox.
-- You can add more functions to the environment
-- (see where local env is defined)
-- Something nice to play is appending minetest.env to it.
-- Something nice to play is is appending minetest.env to it.
local BASENAME = "pipeworks:lua_tube"
@ -79,7 +77,7 @@ local function update_real_port_states(pos, rule_name, new_state)
if rule_name.x == nil then
for _, rname in ipairs(rule_name) do
local port = pos_to_side[rname.x + (2 * rname.y) + (3 * rname.z) + 4]
L[port] = (new_state == "on") and 1 or 0
L[port] = (newstate == "on") and 1 or 0
end
else
local port = pos_to_side[rule_name.x + (2 * rule_name.y) + (3 * rule_name.z) + 4]
@ -170,7 +168,7 @@ local function set_port_states(pos, ports)
-- Solution / Workaround:
-- Remember which output was turned off and ignore next "off" event.
local meta = minetest.get_meta(pos)
local ign = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
local ign = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
if ports.red and not vports.red and not mesecon.is_powered(pos, rules.red) then ign.red = true end
if ports.blue and not vports.blue and not mesecon.is_powered(pos, rules.blue) then ign.blue = true end
if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
@ -216,7 +214,7 @@ end
local function ignore_event(event, meta)
if event.type ~= "off" then return false end
local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
if ignore_offevents[event.pin.name] then
ignore_offevents[event.pin.name] = nil
meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
@ -229,11 +227,7 @@ end
-------------------------
local function safe_print(param)
local string_meta = getmetatable("")
local sandbox = string_meta.__index
string_meta.__index = string -- Leave string sandbox temporarily
print(dump(param))
string_meta.__index = sandbox -- Restore string sandbox
end
local function safe_date()
@ -273,7 +267,6 @@ local function remove_functions(x)
local seen = {}
local function rfuncs(x)
if x == nil then return end
if seen[x] then return end
seen[x] = true
if type(x) ~= "table" then return end
@ -297,174 +290,49 @@ local function remove_functions(x)
return x
end
-- The setting affects API so is not intended to be changeable at runtime
local get_interrupt
if mesecon.setting("luacontroller_lightweight_interrupts", false) then
-- use node timer
get_interrupt = function(pos, itbl, send_warning)
return (function(time, iid)
if type(time) ~= "number" then error("Delay must be a number") end
if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end
table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
end)
end
else
-- use global action queue
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
get_interrupt = function(pos, itbl, send_warning)
-- iid = interrupt id
local function interrupt(time, iid)
-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
-- Hence the values get moved out. Should take less time than original, so totally compatible
if type(time) ~= "number" then error("Delay must be a number") end
table.insert(itbl, function ()
-- Outside string metatable sandbox, can safely run this now
local luac_id = minetest.get_meta(pos):get_int("luac_id")
-- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data.
-- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended.
-- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place
iid = remove_functions(iid)
local msg_ser = minetest.serialize(iid)
if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
else
send_warning("An interrupt ID was too large!")
end
end)
end
return interrupt
end
end
-- Given a message object passed to digiline_send, clean it up into a form
-- which is safe to transmit over the network and compute its "cost" (a very
-- rough estimate of its memory usage).
--
-- The cleaning comprises the following:
-- 1. Functions (and userdata, though user scripts ought not to get hold of
-- those in the first place) are removed, because they break the model of
-- Digilines as a network that carries basic data, and they could exfiltrate
-- references to mutable objects from one Luacontroller to another, allowing
-- inappropriate high-bandwidth, no-wires communication.
-- 2. Tables are duplicated because, being mutable, they could otherwise be
-- modified after the send is complete in order to change what data arrives
-- at the recipient, perhaps in violation of the previous cleaning rule or
-- in violation of the message size limit.
--
-- The cost indication is only approximate; its not a perfect measurement of
-- the number of bytes of memory used by the message object.
--
-- Parameters:
-- msg -- the message to clean
-- back_references -- for internal use only; do not provide
--
-- Returns:
-- 1. The cleaned object.
-- 2. The approximate cost of the object.
local function clean_and_weigh_digiline_message(msg, back_references)
local t = type(msg)
if t == "string" then
-- Strings are immutable so can be passed by reference, and cost their
-- length plus the size of the Lua object header (24 bytes on a 64-bit
-- platform) plus one byte for the NUL terminator.
return msg, #msg + 25
elseif t == "number" then
-- Numbers are passed by value so need not be touched, and cost 8 bytes
-- as all numbers in Lua are doubles.
return msg, 8
elseif t == "boolean" then
-- Booleans are passed by value so need not be touched, and cost 1
-- byte.
return msg, 1
elseif t == "table" then
-- Tables are duplicated. Check if this table has been seen before
-- (self-referential or shared table); if so, reuse the cleaned value
-- of the previous occurrence, maintaining table topology and avoiding
-- infinite recursion, and charge zero bytes for this as the object has
-- already been counted.
back_references = back_references or {}
local bref = back_references[msg]
if bref then
return bref, 0
end
-- Construct a new table by cleaning all the keys and values and adding
-- up their costs, plus 8 bytes as a rough estimate of table overhead.
local cost = 8
local ret = {}
back_references[msg] = ret
for k, v in pairs(msg) do
local k_cost, v_cost
k, k_cost = clean_and_weigh_digiline_message(k, back_references)
v, v_cost = clean_and_weigh_digiline_message(v, back_references)
if k ~= nil and v ~= nil then
-- Only include an element if its key and value are of legal
-- types.
ret[k] = v
end
-- If we only counted the cost of a table element when we actually
-- used it, we would be vulnerable to the following attack:
-- 1. Construct a huge table (too large to pass the cost limit).
-- 2. Insert it somewhere in a table, with a function as a key.
-- 3. Insert it somewhere in another table, with a number as a key.
-- 4. The first occurrence doesnt pay the cost because functions
-- are stripped and therefore the element is dropped.
-- 5. The second occurrence doesnt pay the cost because its in
-- back_references.
-- By counting the costs regardless of whether the objects will be
-- included, we avoid this attack; it may overestimate the cost of
-- some messages, but only those that wont be delivered intact
-- anyway because they contain illegal object types.
cost = cost + k_cost + v_cost
end
return ret, cost
else
return nil, 0
local function get_interrupt(pos)
-- iid = interrupt id
local function interrupt(time, iid)
if type(time) ~= "number" then return end
local luac_id = minetest.get_meta(pos):get_int("luac_id")
mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
end
return interrupt
end
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
local function get_digiline_send(pos, itbl, send_warning)
if not minetest.global_exists("digilines") then return end
local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
local function get_digiline_send(pos)
if not digiline then return end
return function(channel, msg)
-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
-- or via anything that could.
-- Make sure channel is string, number or boolean
if type(channel) == "string" then
if #channel > chan_maxlen then
send_warning("Channel string too long.")
return false
end
elseif (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
send_warning("Channel must be string, number or boolean.")
if (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
return false
end
local msg_cost
msg, msg_cost = clean_and_weigh_digiline_message(msg)
if msg == nil or msg_cost > maxlen then
send_warning("Message was too complex, or contained invalid data.")
-- It is technically possible to send functions over the wire since
-- the high performance impact of stripping those from the data has
-- been decided to not be worth the added realism.
-- Make sure serialized version of the data is not insanely long to
-- prevent DoS-like attacks
local msg_ser = minetest.serialize(msg)
if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
return false
end
table.insert(itbl, function ()
-- Runs outside of string metatable sandbox
local luac_id = minetest.get_meta(pos):get_int("luac_id")
mesecon.queue:add_action(pos, "pipeworks:lt_digiline_relay", {channel, luac_id, msg})
minetest.after(0, function()
digilines.receptor_send(pos, digiline_rules_luatube, channel, msg)
end)
return true
end
end
local safe_globals = {
-- Don't add pcall/xpcall unless willing to deal with the consequences (unless very careful, incredibly likely to allow killing server indirectly)
"assert", "error", "ipairs", "next", "pairs", "select",
"tonumber", "tostring", "type", "unpack", "_VERSION"
}
local function create_environment(pos, mem, event, itbl, send_warning)
local function create_environment(pos, mem, event)
-- Make sure the tube hasn't broken.
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
if not vports then return {} end
@ -484,8 +352,8 @@ local function create_environment(pos, mem, event, itbl, send_warning)
heat = mesecon.get_heat(pos),
heat_max = mesecon.setting("overheat_max", 20),
print = safe_print,
interrupt = get_interrupt(pos, itbl, send_warning),
digiline_send = get_digiline_send(pos, itbl, send_warning),
interrupt = get_interrupt(pos),
digiline_send = get_digiline_send(pos),
string = {
byte = string.byte,
char = string.char,
@ -573,11 +441,10 @@ local function create_sandbox(code, env)
jit.off(f, true)
end
local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
return function(...)
-- NOTE: This runs within string metatable sandbox, so the setting's been moved out for safety
-- Use instruction counter to stop execution
-- after luacontroller_maxevents
local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
debug.sethook(timeout, "", maxevents)
local ok, ret = pcall(f, ...)
debug.sethook() -- Clear hook
@ -588,7 +455,7 @@ end
local function load_memory(meta)
return minetest.deserialize(meta:get_string("lc_memory"), true) or {}
return minetest.deserialize(meta:get_string("lc_memory")) or {}
end
@ -598,7 +465,6 @@ local function save_memory(pos, meta, mem)
if (#memstring <= memsize_max) then
meta:set_string("lc_memory", memstring)
meta:mark_as_private("lc_memory")
else
print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
..#memstring.." required. Controller overheats.")
@ -606,42 +472,26 @@ local function save_memory(pos, meta, mem)
end
end
-- Returns success (boolean), errmsg (string), retval(any, return value of the user supplied code)
-- run (as opposed to run_inner) is responsible for setting up meta according to this output
local function run_inner(pos, code, event)
local function run(pos, event)
local meta = minetest.get_meta(pos)
-- Note: These return success, presumably to avoid changing LC ID.
if overheat(pos) then return true, "", nil end
if ignore_event(event, meta) then return true, "", nil end
if overheat(pos) then return end
if ignore_event(event, meta) then return end
-- Load code & mem from meta
local mem = load_memory(meta)
local code = meta:get_string("code")
-- 'Last warning' label.
local warning = ""
local function send_warning(str)
warning = "Warning: " .. str
end
-- Create environment
local itbl = {}
local env = create_environment(pos, mem, event, itbl, send_warning)
local env = create_environment(pos, mem, event)
-- Create the sandbox and execute code
local f, msg = create_sandbox(code, env)
if not f then return false, msg, nil end
-- Start string true sandboxing
local onetruestring = getmetatable("")
-- If a string sandbox is already up yet inconsistent, something is very wrong
assert(onetruestring.__index == string)
onetruestring.__index = env.string
local success, msg = pcall(f)
onetruestring.__index = string
-- End string true sandboxing
if not success then return false, msg, nil end
if not f then return false, msg end
local succ, msg = pcall(f)
if not succ then return false, msg end
if type(env.port) ~= "table" then
return false, "Ports set are invalid.", nil
return false, "Ports set are invalid."
end
-- Actually set the ports
@ -650,81 +500,35 @@ local function run_inner(pos, code, event)
-- Save memory. This may burn the luacontroller if a memory overflow occurs.
save_memory(pos, meta, env.mem)
-- Execute deferred tasks
for _, v in ipairs(itbl) do
local failure = v()
if failure then
return false, failure, nil
end
end
return true, warning, msg
return succ, msg
end
local function reset_formspec(meta, code, errmsg)
meta:set_string("code", code)
meta:mark_as_private("code")
code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
meta:set_string("formspec", "size[12,10]"
.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
.."label[0.1,8.3;"..errmsg.."]"
.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"
.."image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"
.."image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"
)
end
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
run(pos, {type = "interrupt", iid = iid})
end)
local function reset_meta(pos, code, errmsg)
local meta = minetest.get_meta(pos)
reset_formspec(meta, code, errmsg)
meta:set_string("code", code)
code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
meta:set_string("formspec", "size[12,10]"..
"background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"..
"textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"..
"image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"..
"image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
"label[0.1,9;"..errmsg.."]")
meta:set_int("luac_id", math.random(1, 65535))
end
-- Wraps run_inner with LC-reset-on-error
local function run(pos, event)
local meta = minetest.get_meta(pos)
local code = meta:get_string("code")
local ok, errmsg, retval = run_inner(pos, code, event)
if not ok then
reset_meta(pos, code, errmsg)
else
reset_formspec(meta, code, errmsg)
end
return ok, errmsg, retval
end
local function reset(pos)
set_port_states(pos, {red = false, blue = false, yellow = false,
green = false, black = false, white = false})
end
local function node_timer(pos)
if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then
return false
end
run(pos, {type="interrupt"})
return false
end
-----------------------
-- A.Queue callbacks --
-----------------------
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
run(pos, {type="interrupt", iid = iid})
end)
mesecon.queue:add_function("pipeworks:lt_digiline_relay", function (pos, channel, luac_id, msg)
if not digiline then return end
-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
-- The actual work
digiline:receptor_send(pos, digiline_rules_luatube, channel, msg)
end)
-----------------------
-- Node Registration --
@ -754,7 +558,6 @@ local digiline = {
receptor = {},
effector = {
action = function(pos, node, channel, msg)
msg = clean_and_weigh_digiline_message(msg)
run(pos, {type = "digiline", channel = channel, msg = msg})
end
},
@ -762,18 +565,6 @@ local digiline = {
rules = pipeworks.digilines_rules
},
}
local function get_program(pos)
local meta = minetest.get_meta(pos)
return meta:get_string("code")
end
local function set_program(pos, code)
reset(pos)
reset_meta(pos, code)
return run(pos, {type="program"})
end
local function on_receive_fields(pos, form_name, fields, sender)
if not fields.program then
return
@ -783,10 +574,12 @@ local function on_receive_fields(pos, form_name, fields, sender)
minetest.record_protection_violation(pos, name)
return
end
local ok, err = set_program(pos, fields.code)
if not ok then
-- it's not an error from the server perspective
minetest.log("action", "Lua controller programming error: " .. tostring(err))
reset(pos)
reset_meta(pos, fields.code)
local succ, err = run(pos, {type="program"})
if not succ then
print(err)
reset_meta(pos, fields.code, err)
end
end
@ -922,11 +715,7 @@ for white = 0, 1 do
receptor = {
state = mesecon.state.on,
rules = output_rules[cid]
},
luacontroller = {
get_program = get_program,
set_program = set_program,
},
}
}
minetest.register_node(node_name, {
@ -934,7 +723,6 @@ for white = 0, 1 do
drawtype = "nodebox",
tiles = tiles,
paramtype = "light",
is_ground_content = false,
groups = groups,
drop = BASENAME.."000000",
sunlight_propagates = true,
@ -961,7 +749,6 @@ for white = 0, 1 do
pipeworks.after_dig(pos, node)
end,
is_luacontroller = true,
on_timer = node_timer,
tubelike = 1,
tube = {
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
@ -975,7 +762,7 @@ for white = 0, 1 do
break
end
end
local succ, _, msg = run(pos, {
local succ, msg = run(pos, {
type = "item",
pin = src,
itemstring = stack:to_string(),
@ -998,6 +785,14 @@ for white = 0, 1 do
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end,
on_blast = function(pos, intensity)
if not intensity or intensity > 1 + 3^0.5 then
minetest.remove_node(pos)
return {string.format("%s_%s", name, dropname)}
end
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
pipeworks.scan_for_tube_objects(pos)
end,
})
end
end
@ -1041,7 +836,6 @@ minetest.register_node(BASENAME .. "_burnt", {
tiles = tiles_burnt,
is_burnt = true,
paramtype = "light",
is_ground_content = false,
groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1},
drop = BASENAME.."000000",
sunlight_propagates = true,

View File

@ -340,8 +340,6 @@ local move_entities_globalstep_part2 = function(dtime)
entity._velocity = master_entity:get_velocity()
entity._acceleration = master_entity:get_acceleration()
else
entity._velocity = entity._velocity or vector.new(0,0,0)
entity._acceleration = entity._acceleration or vector.new(0,0,0)
entity._pos = vector.add(vector.add(
entity._pos,
vector.multiply(entity._velocity, dtime)),

View File

@ -1,5 +1 @@
name = pipeworks
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
depends = default, basic_materials, screwdriver
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib
min_minetest_version = 5.2.0

View File

@ -1,5 +1,4 @@
-- This file supplies the steel pipes
local S = minetest.get_translator("pipeworks")
local REGISTER_COMPATIBILITY = true
@ -36,11 +35,11 @@ for index, connects in ipairs(cconnects) do
end
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
local pipedesc = S("Pipe Segment").." "..dump(connects)
local pipedesc = "Pipe segement".." "..dump(connects).."... You hacker, you."
if #connects == 0 then
pgroups = {snappy = 3, tube = 1}
pipedesc = S("Pipe Segment")
pipedesc = "Pipe segment"
end
local outimg_e = { "pipeworks_pipe_plain.png" }
@ -141,7 +140,7 @@ if REGISTER_COMPATIBILITY then
drawtype = "airlike",
sunlight_propagates = true,
paramtype = "light",
description = S("Pipe Segment (legacy)"),
description = "Pipe Segment (legacy)",
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos)

View File

@ -1,6 +1,6 @@
local S = minetest.get_translator("pipeworks")
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", S("Pneumatic tube segment"))
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
minetest.register_craft( {
output = "pipeworks:tube_1 6",
recipe = {
@ -13,7 +13,7 @@ minetest.register_craft( {
local nodecolor = 0xffff3030
pipeworks.register_tube("pipeworks:broken_tube", {
description = S("Broken Tube"),
description = "Broken Tube (you hacker you)",
plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
ends = { { name = "pipeworks_broken_tube_end.png", color = nodecolor } },
@ -35,7 +35,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
local itemstack = puncher:get_wielded_item()
local wieldname = itemstack:get_name()
local playername = puncher:get_player_name()
local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n"
print("[Pipeworks] "..playername.." struck a broken tube at "..minetest.pos_to_string(pos))
if wieldname == "anvil:hammer"
or wieldname == "cottages:hammer"
or wieldname == "glooptest:hammer_steel"
@ -47,17 +47,17 @@ pipeworks.register_tube("pipeworks:broken_tube", {
local meta = minetest.get_meta(pos)
local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
if was_node and was_node ~= "" then
pipeworks.logger(log_msg.." with "..wieldname.." to repair it.")
print(" with "..wieldname.." to repair it.")
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
pipeworks.scan_for_tube_objects(pos)
itemstack:add_wear(1000)
puncher:set_wielded_item(itemstack)
return itemstack
else
pipeworks.logger(log_msg.." but it can't be repaired.")
print(" but it can't be repaired.")
end
else
pipeworks.logger(log_msg.." with "..wieldname.." but that tool is too weak.")
print(" with "..wieldname.." but that tool is too weak.")
end
end
}
@ -69,7 +69,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
if pipeworks.enable_priority_tube then
local color = "#ff3030:128"
pipeworks.register_tube("pipeworks:priority_tube", {
description = S("High Priority Tube Segment"),
description = "High Priority Tube Segment",
inventory_image = "pipeworks_tube_inv.png^[colorize:" .. color,
plain = { { name = "pipeworks_tube_plain.png", color = nodecolor } },
noctr = { { name = "pipeworks_tube_noctr.png", color = nodecolor } },
@ -91,7 +91,7 @@ end
if pipeworks.enable_accelerator_tube then
pipeworks.register_tube("pipeworks:accelerator_tube", {
description = S("Accelerating Pneumatic Tube Segment"),
description = "Accelerating Pneumatic Tube Segment",
inventory_image = "pipeworks_accelerator_tube_inv.png",
plain = { "pipeworks_accelerator_tube_plain.png" },
noctr = { "pipeworks_accelerator_tube_noctr.png" },
@ -116,7 +116,7 @@ end
if pipeworks.enable_crossing_tube then
pipeworks.register_tube("pipeworks:crossing_tube", {
description = S("Crossing Pneumatic Tube Segment"),
description = "Crossing Pneumatic Tube Segment",
inventory_image = "pipeworks_crossing_tube_inv.png",
plain = { "pipeworks_crossing_tube_plain.png" },
noctr = { "pipeworks_crossing_tube_noctr.png" },
@ -138,7 +138,7 @@ end
if pipeworks.enable_one_way_tube then
minetest.register_node("pipeworks:one_way_tube", {
description = S("One way tube"),
description = "One way tube",
tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
paramtype2 = "facedir",

View File

@ -1,8 +1,7 @@
local S = minetest.get_translator("pipeworks")
if pipeworks.enable_detector_tube then
local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", {
description = S("Detecting Pneumatic Tube Segment on"),
description = "Detecting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
@ -41,7 +40,7 @@ if pipeworks.enable_detector_tube then
},
})
pipeworks.register_tube("pipeworks:detector_tube_off", {
description = S("Detecting Pneumatic Tube Segment"),
description = "Detecting Pneumatic Tube Segment",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
@ -71,7 +70,7 @@ end
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
pipeworks.register_tube("pipeworks:digiline_detector_tube", {
description = S("Digiline Detecting Pneumatic Tube Segment"),
description = "Digiline Detecting Pneumatic Tube Segment",
inventory_image = "pipeworks_digiline_detector_tube_inv.png",
plain = { "pipeworks_digiline_detector_tube_plain.png" },
node_def = {
@ -80,7 +79,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
local setchan = meta:get_string("channel")
digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_table())
digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_string())
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end},
@ -88,9 +87,9 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8.6,2.2]"..
"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]"..
"field[0.6,0.6;8,1;channel;Channel:;${channel}]"..
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.6,1.2;"..S("Digiline Detecting Tube").."]"
"label[1.6,1.2;Digiline Detecting Tube]"
)
end,
on_receive_fields = function(pos, formname, fields, sender)
@ -123,7 +122,7 @@ end
if pipeworks.enable_conductor_tube then
pipeworks.register_tube("pipeworks:conductor_tube_off", {
description = S("Conducting Pneumatic Tube Segment"),
description = "Conducting Pneumatic Tube Segment",
inventory_image = "pipeworks_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png",
plain = { "pipeworks_conductor_tube_plain.png" },
@ -137,7 +136,7 @@ if pipeworks.enable_conductor_tube then
},
})
pipeworks.register_tube("pipeworks:conductor_tube_on", {
description = S("Conducting Pneumatic Tube Segment on"),
description = "Conducting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png",
plain = { "pipeworks_conductor_tube_on_plain.png" },
@ -161,7 +160,7 @@ end
if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
description = S("Digiline Conducting Pneumatic Tube Segment"),
description = "Digiline Conducting Pneumatic Tube Segment",
inventory_image = "pipeworks_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
short = "pipeworks_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
@ -179,7 +178,7 @@ end
if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
pipeworks.enable_conductor_tube then
pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_off", {
description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment"),
description = "Mesecon and Digiline Conducting Pneumatic Tube Segment",
inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
plain = {"pipeworks_conductor_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
@ -196,7 +195,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
},
})
pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_on", {
description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment on"),
description = "Mesecon and Digiline Conducting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
plain = {"pipeworks_conductor_tube_on_plain.png^pipeworks_digiline_conductor_tube_plain.png"},

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local fs_helpers = pipeworks.fs_helpers
if pipeworks.enable_mese_tube then
@ -56,7 +55,7 @@ if pipeworks.enable_mese_tube then
end
pipeworks.register_tube("pipeworks:mese_tube", {
description = S("Sorting Pneumatic Tube Segment"),
description = "Sorting Pneumatic Tube Segment",
inventory_image = "pipeworks_mese_tube_inv.png",
noctr = {"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"},
@ -108,7 +107,7 @@ if pipeworks.enable_mese_tube then
inv:set_size("line"..tostring(i), 6*1)
end
update_formspec(pos)
meta:set_string("infotext", S("Sorting pneumatic tube"))
meta:set_string("infotext", "Sorting pneumatic tube")
end,
on_punch = update_formspec,
on_receive_fields = function(pos, formname, fields, sender)

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local filename=minetest.get_worldpath() .. "/teleport_tubes"
local tp_tube_db = nil -- nil forces a read
@ -128,19 +127,19 @@ local function update_meta(meta, can_receive)
meta:set_int("can_receive", can_receive and 1 or 0)
local cr_state = can_receive and "on" or "off"
meta:set_string("formspec","size[8.6,2.2]"..
"field[0.6,0.6;7,1;channel;"..S("Channel")..";${channel}]"..
"label[7.3,0;"..S("Receive").."]"..
"field[0.6,0.6;7,1;channel;Channel:;${channel}]"..
"label[7.3,0;Receive]"..
"image_button[7.3,0.3;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.6,1.2;"..S("channels are public by default").."]" ..
"label[1.6,1.5;"..S("use <player>:<channel> for fully private channels").."]" ..
"label[1.6,1.8;"..S("use <player>\\;<channel> for private receivers").."]" ..
"label[1.6,1.2;channels are public by default]" ..
"label[1.6,1.5;use <player>:<channel> for fully private channels]" ..
"label[1.6,1.8;use <player>\\;<channel> for private receivers]" ..
default.gui_bg..
default.gui_bg_img)
end
pipeworks.register_tube("pipeworks:teleport_tube", {
description = S("Teleporting Pneumatic Tube Segment"),
description = "Teleporting Pneumatic Tube Segment",
inventory_image = "pipeworks_teleport_tube_inv.png",
noctr = { "pipeworks_teleport_tube_noctr.png" },
plain = { "pipeworks_teleport_tube_plain.png" },
@ -170,7 +169,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
update_meta(meta, true)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", "unconfigured Teleportation Tube")
end,
on_receive_fields = function(pos,formname,fields,sender)
if not fields.channel -- ignore escaping or clientside manipulation of the form
@ -190,14 +189,12 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
if name and mode and name ~= sender_name then
--channels starting with '[name]:' can only be used by the named player
if mode == ":" then
minetest.chat_send_player(sender_name, S("Sorry, channel '@1' is reserved for exclusive use by @2",
new_channel, name))
minetest.chat_send_player(sender_name, "Sorry, channel '"..new_channel.."' is reserved for exclusive use by "..name)
return
--channels starting with '[name];' can be used by other players, but cannot be received from
elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
minetest.chat_send_player(sender_name, S("Sorry, receiving from channel '@1' is reserved for @2",
new_channel, name))
minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..new_channel.."' is reserved for "..name)
return
end
end
@ -229,11 +226,11 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
if channel ~= "" then
set_tube(pos, channel, can_receive)
local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel))
meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
else
-- remove empty channel tubes, to not have to search through them
remove_tube(pos)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", "unconfigured Teleportation Tube")
end
end
end,
@ -261,11 +258,3 @@ if minetest.get_modpath("mesecons_mvps") ~= nil then
end
end)
end
-- Expose teleport tube database API for other mods
pipeworks.tptube = {
hash = hash,
save_tube_db = save_tube_db,
get_db = function() return tp_tube_db or read_tube_db() end,
tp_tube_db_version = tp_tube_db_version
}

View File

@ -1,6 +1,5 @@
local S = minetest.get_translator("pipeworks")
minetest.register_node("pipeworks:trashcan", {
description = S("Trash Can"),
description = "Trash Can",
drawtype = "normal",
tiles = {
"pipeworks_trashcan_bottom.png",
@ -23,7 +22,7 @@ minetest.register_node("pipeworks:trashcan", {
meta:set_string("formspec",
"size[8,7]"..
"item_image[0,0;1,1;pipeworks:trashcan]"..
"label[1,0;"..S("Trash Can").."]"..
"label[1,0;Trash Can]"..
"list[context;trash;3.5,1;1,1;]"..
default.gui_bg..
default.gui_bg_img..
@ -31,7 +30,7 @@ minetest.register_node("pipeworks:trashcan", {
default.get_hotbar_bg(0,3) ..
"list[current_player;main;0,3;8,4;]" ..
"listring[]")
meta:set_string("infotext", S("Trash Can"))
meta:set_string("infotext", "Trash Can")
meta:get_inventory():set_size("trash", 1)
end,
after_place_node = pipeworks.after_place,

View File

@ -1,5 +1,4 @@
-- This file supplies the various kinds of pneumatic tubes
local S = minetest.get_translator("pipeworks")
local tubenodes = {}
pipeworks.tubenodes = tubenodes
@ -57,8 +56,8 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
end
local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1}
local tubedesc = string.format("%s %s", desc, dump(connects))
local iimg = type(plain[1]) == "table" and plain[1].name or plain[1]
local tubedesc = string.format("%s %s... You hacker, you.", desc, dump(connects))
local iimg = plain[1]
local wscale = {x = 1, y = 1, z = 1}
if #connects == 0 then
@ -198,7 +197,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
wield_image = inv,
paramtype = "light",
sunlight_propagates = true,
description = S("Pneumatic tube segment (legacy)"),
description = "Pneumatic tube segment (legacy)",
after_place_node = pipeworks.after_place,
groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}},

View File

@ -1,7 +1,6 @@
local S = minetest.get_translator("pipeworks")
if pipeworks.enable_sand_tube then
pipeworks.register_tube("pipeworks:sand_tube", {
description = S("Vacuuming Pneumatic Tube Segment"),
description = "Vacuuming Pneumatic Tube Segment",
inventory_image = "pipeworks_sand_tube_inv.png",
short = "pipeworks_sand_tube_short.png",
noctr = {"pipeworks_sand_tube_noctr.png"},
@ -29,7 +28,7 @@ end
if pipeworks.enable_mese_sand_tube then
pipeworks.register_tube("pipeworks:mese_sand_tube", {
description = S("Adjustable Vacuuming Pneumatic Tube Segment"),
description = "Adjustable Vacuuming Pneumatic Tube Segment",
inventory_image = "pipeworks_mese_sand_tube_inv.png",
short = "pipeworks_mese_sand_tube_short.png",
noctr = {"pipeworks_mese_sand_tube_noctr.png"},
@ -45,7 +44,7 @@ if pipeworks.enable_mese_sand_tube then
"field[1.3,0.4;1,1;dist;radius;${dist}]"..
default.gui_bg..
default.gui_bg_img)
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment"))
meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment")
end,
on_receive_fields = function(pos,formname,fields,sender)
if not pipeworks.may_configure(pos, sender) then return end
@ -55,7 +54,7 @@ if pipeworks.enable_mese_sand_tube then
dist = math.max(0, dist)
dist = math.min(8, dist)
meta:set_int("dist", dist)
meta:set_string("infotext", (S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist)))
meta:set_string("infotext", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
end
end,
},

View File

@ -1,4 +1,3 @@
local S = minetest.get_translator("pipeworks")
local assumed_eye_pos = vector.new(0, 1.5, 0)
local function vector_copy(v)
@ -40,7 +39,7 @@ local can_tool_dig_node = function(nodename, toolcaps, toolname)
-- but a player holding one can - the game seems to fall back to the hand.
-- fall back to checking the hand's properties if the tool isn't the correct one.
local hand_caps = minetest.registered_items[""].tool_capabilities
diggable = minetest.get_dig_params(nodegroups, hand_caps).diggable
diggable = minetest.get_dig_params(nodegroups, hand_caps)
end
return diggable
end
@ -260,7 +259,7 @@ if pipeworks.enable_node_breaker then
local wield_inv_name = "pick"
data = {
name_base = name_base,
description = S("Node Breaker"),
description = "Node Breaker",
texture_base = "pipeworks_nodebreaker",
texture_stateful = { top = true, bottom = true, side2 = true, side1 = true, front = true },
tube_connect_sides = { top=1, bottom=1, left=1, right=1, back=1 },
@ -378,7 +377,7 @@ if pipeworks.enable_node_breaker then
minetest.register_craft({
output = "pipeworks:nodebreaker_off",
recipe = {
{ "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" },
{ "pipeworks:gear", "pipeworks:gear", "pipeworks:gear" },
{ "default:stone", "mesecons:piston", "default:stone" },
{ "group:wood", "mesecons:mesecon", "group:wood" },
}
@ -409,7 +408,7 @@ end
if pipeworks.enable_deployer then
register_wielder({
name_base = "pipeworks:deployer",
description = S("Deployer"),
description = "Deployer",
texture_base = "pipeworks_deployer",
texture_stateful = { front = true },
tube_connect_sides = { back=1 },
@ -442,7 +441,7 @@ end
if pipeworks.enable_dispenser then
register_wielder({
name_base = "pipeworks:dispenser",
description = S("Dispenser"),
description = "Dispenser",
texture_base = "pipeworks_dispenser",
texture_stateful = { front = true },
tube_connect_sides = { back=1 },