1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-07-19 16:50:28 +02:00

28 Commits

Author SHA1 Message Date
2f9f9a7b54 Merge remote-tracking branch 'upstream/master' 2023-11-23 00:15:18 +01:00
02322855d5 Merge remote-tracking branch 'upstream/master' 2023-06-07 22:19:10 +02:00
b11cb37123 Merge remote-tracking branch 'upstream/master' 2022-08-26 15:22:54 +02:00
503c1190ed Merge remote-tracking branch 'upstream/master' 2022-06-25 16:52:37 +02:00
5bba517b03 Merge remote-tracking branch 'upstream/master' 2022-05-27 18:46:28 +02:00
66070dd801 Merge remote-tracking branch 'upstream/master' 2022-03-06 16:37:56 +01:00
7ee74133e1 Merge remote-tracking branch 'upstream/master' 2021-06-20 17:21:30 +02:00
c01bd7b888 Merge remote-tracking branch 'upstream/master' 2021-05-09 21:42:46 +02:00
e2fdcc4fb2 Merge remote-tracking branch 'upstream/master' 2021-04-08 13:32:05 +02:00
e4db1e885e Merge remote-tracking branch 'upstream/master' 2021-04-04 21:02:57 +02:00
f7839444cd Merge remote-tracking branch 'upstream/master' 2021-03-25 21:57:03 +01:00
93f5fb3d87 Merge remote-tracking branch 'upstream/master' 2021-03-12 12:36:16 +01:00
a535bebd2e Merge remote-tracking branch 'upstream/master' 2021-02-13 14:18:53 +01:00
be2776fc46 Merge remote-tracking branch 'upstream/master' 2021-02-07 13:13:20 +01:00
ee03959a65 Merge remote-tracking branch 'upstream/master' 2020-12-20 15:26:00 +01:00
4dd30df37a Merge remote-tracking branch 'upstream/master' 2020-10-29 22:16:20 +01:00
946da11206 Merge remote-tracking branch 'upstream/master' 2020-10-18 02:13:58 +02:00
77c8026400 Merge remote-tracking branch 'upstream/master' 2020-09-26 11:40:25 +02:00
70b521c721 Merge remote-tracking branch 'upstream/master' 2020-09-11 20:50:17 +02:00
6d795b7d34 Merge remote-tracking branch 'upstream/master' 2020-08-11 20:30:19 +02:00
92249b7941 Merge remote-tracking branch 'upstream/master' 2020-07-31 22:18:16 +02:00
e04fb691ad Merge remote-tracking branch 'upstream/master' 2020-07-19 22:41:58 +02:00
ac80224371 Merge remote-tracking branch 'upstream/master' 2020-07-17 22:41:46 +02:00
34262ed8d5 Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev 2020-06-14 21:11:09 +02:00
5cfe8d893f Merge branch 'master' of yunohost.local:mtcontrib/pipeworks into nalc-1.2-dev 2020-03-25 23:00:57 +01:00
975e20f704 Merge branch 'master' of yunohost.local:mtcontrib/pipeworks into nalc-1.2-dev 2019-12-22 14:33:13 +01:00
2693e2ecbb Merge branch 'master' into nalc-1.2 2019-05-04 19:56:03 +02:00
c93df73a5c Rend les items du groupe limitcraft non craftable par l'autocrafter 2019-03-02 19:29:26 +01:00
42 changed files with 476 additions and 1117 deletions

View File

@ -1,10 +1,13 @@
name: luacheck name: luacheck
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
luacheck: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@master
uses: actions/checkout@master - name: apt
- name: Luacheck run: sudo apt-get install -y luarocks
uses: lunarmodules/luacheck@master - name: luacheck install
run: luarocks install --local luacheck
- name: luacheck run
run: $HOME/.luarocks/bin/luacheck ./

View File

@ -20,7 +20,6 @@ read_globals = {
-- mods -- mods
"default", "mesecon", "digiline", "default", "mesecon", "digiline",
"screwdriver", "unified_inventory", "screwdriver", "unified_inventory",
"i3", "mcl_experience", "awards", "i3", "mcl_experience", "awards"
"xcompat",
} }

View File

@ -1,15 +1,11 @@
local S = minetest.get_translator("pipeworks") local S = minetest.get_translator("pipeworks")
-- cache some recipe data to avoid calling the slow function local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
-- minetest.get_craft_result() every second
local autocrafterCache = {}
local craft_time = 1 local craft_time = 1
local next = next
local function count_index(invlist) local function count_index(invlist)
local index = {} local index = {}
for _, stack in pairs(invlist) do for _, stack in pairs(invlist) do
stack = ItemStack(stack)
if not stack:is_empty() then if not stack:is_empty() then
local stack_name = stack:get_name() local stack_name = stack:get_name()
index[stack_name] = (index[stack_name] or 0) + stack:get_count() index[stack_name] = (index[stack_name] or 0) + stack:get_count()
@ -25,177 +21,41 @@ local function get_item_info(stack)
return description, name return description, name
end end
-- Get best matching recipe for what user has put in crafting grid.
-- This function does not consider crafting method (mix vs craft)
local function get_matching_craft(output_name, example_recipe)
local recipes = minetest.get_all_craft_recipes(output_name)
if not recipes then
return example_recipe
end
if 1 == #recipes then
return recipes[1].items
end
local index_example = count_index(example_recipe)
local best_score = 0
local index_recipe, best_index, score, group
for i = 1, #recipes do
score = 0
index_recipe = count_index(recipes[i].items)
for recipe_item_name, _ in pairs(index_recipe) do
if index_example[recipe_item_name] then
score = score + 1
elseif recipe_item_name:sub(1, 6) == "group:" then
group = recipe_item_name:sub(7)
for example_item_name, _ in pairs(index_example) do
if minetest.get_item_group(
example_item_name, group) ~= 0
then
score = score + 1
break
end
end
end
end
if best_score < score then
best_index = i
best_score = score
end
end
return best_index and recipes[best_index].items or example_recipe
end
local function get_craft(pos, inventory, hash) local function get_craft(pos, inventory, hash)
local hash = hash or minetest.hash_node_position(pos) local hash = hash or minetest.hash_node_position(pos)
local craft = autocrafterCache[hash] local craft = autocrafterCache[hash]
if craft then return craft end if not craft then
local recipe = inventory:get_list("recipe")
local example_recipe = inventory:get_list("recipe") local output, decremented_input = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
local output, decremented_input = minetest.get_craft_result({ craft = {recipe = recipe, consumption=count_index(recipe), output = output, decremented_input = decremented_input}
method = "normal", width = 3, items = example_recipe
})
local recipe = example_recipe
if output and not output.item:is_empty() then
recipe = get_matching_craft(output.item:get_name(), example_recipe)
end
craft = {
recipe = recipe,
consumption = count_index(recipe),
output = output,
decremented_input = decremented_input.items
}
autocrafterCache[hash] = craft autocrafterCache[hash] = craft
end
return craft return craft
end end
-- From a consumption table with groups and an inventory index, local function autocraft(inventory, craft)
-- build a consumption table without groups if not craft then return false end
local function calculate_consumption(inv_index, consumption_with_groups) -- check if we have enough material available
inv_index = table.copy(inv_index) local inv_index = count_index(inventory:get_list("src"))
consumption_with_groups = table.copy(consumption_with_groups) for itemname, number in pairs(craft.consumption) do
if (not inv_index[itemname]) or inv_index[itemname] < number then return false end
-- table of items to actually consume
local consumption = {}
-- table of ingredients defined as one or more groups each
local grouped_ingredients = {}
-- First consume all non-group requirements
-- This is done to avoid consuming a non-group item which
-- is also in a group
for key, count in pairs(consumption_with_groups) do
if key:sub(1, 6) == "group:" then
-- build table with group recipe items while looping
grouped_ingredients[key] = key:sub(7):split(',')
else
-- if the item to consume doesn't exist in inventory
-- or not enough of them, abort crafting
if not inv_index[key] or inv_index[key] < count then
return nil
end end
-- check if output and all replacements fit in dst
consumption[key] = (consumption[key] or 0) + count local output = craft.output.item
consumption_with_groups[key] = consumption_with_groups[key] - count local out_items = count_index(craft.decremented_input.items)
assert(consumption_with_groups[key] == 0) out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count()
consumption_with_groups[key] = nil
inv_index[key] = inv_index[key] - count
assert(inv_index[key] >= 0)
end
end
-- helper function to resolve matching ingredients with multiple group
-- requirements
local function ingredient_groups_match_item(ingredient_groups, name)
local found = 0
local count_ingredient_groups = #ingredient_groups
for i = 1, count_ingredient_groups do
if minetest.get_item_group(name,
ingredient_groups[i]) ~= 0
then
found = found + 1
end
end
return found == count_ingredient_groups
end
-- Next, resolve groups using the remaining items in the inventory
if next(grouped_ingredients) ~= nil then
local take
for itemname, count in pairs(inv_index) do
if count > 0 then
-- groupname is the string as defined by recipe.
-- e.g. group:dye,color_blue
-- groups holds the group names split into a list
-- ready to be passed to core.get_item_group()
for groupname, groups in pairs(grouped_ingredients) do
if consumption_with_groups[groupname] > 0
and ingredient_groups_match_item(groups, itemname)
then
take = math.min(count,
consumption_with_groups[groupname])
consumption_with_groups[groupname] =
consumption_with_groups[groupname] - take
assert(consumption_with_groups[groupname] >= 0)
consumption[itemname] =
(consumption[itemname] or 0) + take
inv_index[itemname] =
inv_index[itemname] - take
assert(inv_index[itemname] >= 0)
end
end
end
end
end
-- Finally, check everything has been consumed
for key, count in pairs(consumption_with_groups) do
if count > 0 then
return nil
end
end
return consumption
end
local function has_room_for_output(list_output, index_output)
local name
local empty_count = 0 local empty_count = 0
for _, item in pairs(list_output) do for _,item in pairs(inventory:get_list("dst")) do
if item:is_empty() then if item:is_empty() then
empty_count = empty_count + 1 empty_count = empty_count + 1
else else
name = item:get_name() local name = item:get_name()
if index_output[name] then if out_items[name] then
index_output[name] = index_output[name] - item:get_free_space() out_items[name] = out_items[name] - item:get_free_space()
end end
end end
end end
for _, count in pairs(index_output) do for _,count in pairs(out_items) do
if count > 0 then if count > 0 then
empty_count = empty_count - 1 empty_count = empty_count - 1
end end
@ -203,61 +63,32 @@ local function has_room_for_output(list_output, index_output)
if empty_count < 0 then if empty_count < 0 then
return false return false
end end
return true
end
local function autocraft(inventory, craft)
if not craft then return false end
-- check if output and all replacements fit in dst
local output = craft.output.item
local out_items = count_index(craft.decremented_input)
out_items[output:get_name()] =
(out_items[output:get_name()] or 0) + output:get_count()
if not has_room_for_output(inventory:get_list("dst"), out_items) then
return false
end
-- check if we have enough material available
local inv_index = count_index(inventory:get_list("src"))
local consumption = calculate_consumption(inv_index, craft.consumption)
if not consumption then
return false
end
-- consume material -- consume material
for itemname, number in pairs(consumption) do for itemname, number in pairs(craft.consumption) do
-- We have to do that since remove_item does not work if count > stack_max for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max
for _ = 1, number do
inventory:remove_item("src", ItemStack(itemname)) inventory:remove_item("src", ItemStack(itemname))
end end
end end
-- craft the result into the dst inventory and add any "replacements" as well -- craft the result into the dst inventory and add any "replacements" as well
inventory:add_item("dst", output) inventory:add_item("dst", output)
local leftover
for i = 1, 9 do for i = 1, 9 do
leftover = inventory:add_item("dst", craft.decremented_input[i]) inventory:add_item("dst", craft.decremented_input.items[i])
if leftover and not leftover:is_empty() then
minetest.log("warning", "[pipeworks] autocrafter didn't " ..
"calculate output space correctly.")
end
end end
return true return true
end end
-- returns false to stop the timer, true to continue running -- returns false to stop the timer, true to continue running
-- is started only from start_autocrafter(pos) after sanity checks and -- is started only from start_autocrafter(pos) after sanity checks and cached recipe
-- recipe is cached
local function run_autocrafter(pos, elapsed) local function run_autocrafter(pos, elapsed)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory() local inventory = meta:get_inventory()
local craft = get_craft(pos, inventory) local craft = get_craft(pos, inventory)
local output_item = craft.output.item 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 -- only use crafts that have an actual result
if output_item:is_empty() then -- 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", S("unconfigured Autocrafter: unknown recipe")) meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
return false return false
end end
@ -286,17 +117,33 @@ end
-- note, that this function assumes allready being updated to virtual items -- note, that this function assumes allready being updated to virtual items
-- and doesn't handle recipes with stacksizes > 1 -- and doesn't handle recipes with stacksizes > 1
local function after_recipe_change(pos, inventory) local function after_recipe_change(pos, inventory)
local hash = minetest.hash_node_position(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
autocrafterCache[hash] = nil
-- if we emptied the grid, there's no point in keeping it running or cached -- if we emptied the grid, there's no point in keeping it running or cached
if inventory:is_empty("recipe") then if inventory:is_empty("recipe") then
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
autocrafterCache[minetest.hash_node_position(pos)] = nil
meta:set_string("infotext", S("unconfigured Autocrafter")) meta:set_string("infotext", S("unconfigured Autocrafter"))
inventory:set_stack("output", 1, "") inventory:set_stack("output", 1, "")
return return
end end
local craft = get_craft(pos, inventory, hash) local recipe = inventory:get_list("recipe")
local hash = minetest.hash_node_position(pos)
local craft = autocrafterCache[hash]
if craft then
-- check if it changed
local cached_recipe = craft.recipe
for i = 1, 9 do
if recipe[i]:get_name() ~= cached_recipe[i]:get_name() then
autocrafterCache[hash] = nil -- invalidate recipe
craft = nil
break
end
end
end
craft = craft or get_craft(pos, inventory, hash)
local output_item = craft.output.item local output_item = craft.output.item
local description, name = get_item_info(output_item) local description, name = get_item_info(output_item)
meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name)) meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name))
@ -305,8 +152,7 @@ local function after_recipe_change(pos, inventory)
after_inventory_change(pos) after_inventory_change(pos)
end end
-- clean out unknown items and groups, which would be handled like unknown -- clean out unknown items and groups, which would be handled like unknown items in the crafting grid
-- items in the crafting grid
-- if minetest supports query by group one day, this might replace them -- if minetest supports query by group one day, this might replace them
-- with a canonical version instead -- with a canonical version instead
local function normalize(item_list) local function normalize(item_list)
@ -337,14 +183,12 @@ local function on_output_change(pos, inventory, stack)
end end
width_idx = (width_idx < 3) and (width_idx + 1) or 1 width_idx = (width_idx < 3) and (width_idx + 1) or 1
end end
-- we'll set the output slot in after_recipe_change to the actual -- we'll set the output slot in after_recipe_change to the actual result of the new recipe
-- result of the new recipe
end end
after_recipe_change(pos, inventory) after_recipe_change(pos, inventory)
end end
-- returns false if we shouldn't bother attempting to start the timer again -- returns false if we shouldn't bother attempting to start the timer again after this
-- after this
local function update_meta(meta, enabled) local function update_meta(meta, enabled)
local state = enabled and "on" or "off" local state = enabled and "on" or "off"
meta:set_int("enabled", enabled and 1 or 0) meta:set_int("enabled", enabled and 1 or 0)
@ -353,20 +197,17 @@ local function update_meta(meta, enabled)
list_backgrounds = "style_type[box;colors=#666]" list_backgrounds = "style_type[box;colors=#666]"
for i=0, 2 do for i=0, 2 do
for j=0, 2 do for j=0, 2 do
list_backgrounds = list_backgrounds .. "box[" .. list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
0.22 + (i * 1.25) .. "," .. 0.22 + (j * 1.25) .. ";1,1;]"
end end
end end
for i=0, 3 do for i=0, 3 do
for j=0, 2 do for j=0, 2 do
list_backgrounds = list_backgrounds .. "box[" .. list_backgrounds = list_backgrounds .. "box[".. 5.28+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
5.28 + (i * 1.25) .. "," .. 0.22 + (j * 1.25) .. ";1,1;]"
end end
end end
for i=0, 7 do for i=0, 7 do
for j=0, 2 do for j=0, 2 do
list_backgrounds = list_backgrounds .. "box[" .. list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 5+(j*1.25) ..";1,1;]"
0.22 + (i * 1.25) .. "," .. 5 + (j * 1.25) .. ";1,1;]"
end end
end end
end end
@ -379,8 +220,7 @@ local function update_meta(meta, enabled)
"list[context;recipe;0.22,0.22;3,3;]".. "list[context;recipe;0.22,0.22;3,3;]"..
"image[4,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]".. "image[4,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]"..
"list[context;output;4,1.45;1,1;]".. "list[context;output;4,1.45;1,1;]"..
"image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. "image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
state .. ";;;false;pipeworks_button_interm.png]" ..
"list[context;dst;5.28,0.22;4,3;]".. "list[context;dst;5.28,0.22;4,3;]"..
"list[context;src;0.22,5;8,3;]".. "list[context;src;0.22,5;8,3;]"..
pipeworks.fs_helpers.get_inv(9).. pipeworks.fs_helpers.get_inv(9)..
@ -390,8 +230,7 @@ local function update_meta(meta, enabled)
"listring[context;dst]" .. "listring[context;dst]" ..
"listring[current_player;main]" "listring[current_player;main]"
if minetest.get_modpath("digilines") then if minetest.get_modpath("digilines") then
fs = fs .. "field[0.22,4.1;4.5,0.75;channel;" .. S("Channel") .. fs = fs.."field[0.22,4.1;4.5,0.75;channel;"..S("Channel")..";${channel}]"..
";${channel}]" ..
"button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]".. "button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]"..
"button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]" "button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]"
end end
@ -415,12 +254,9 @@ local function update_meta(meta, enabled)
end end
-- 1st version of the autocrafter had actual items in the crafting grid -- 1st version of the autocrafter had actual items in the crafting grid
-- the 2nd replaced these with virtual items, dropped the content on update and -- the 2nd replaced these with virtual items, dropped the content on update and set "virtual_items" to string "1"
-- set "virtual_items" to string "1" -- the third added an output inventory, changed the formspec and added a button for enabling/disabling
-- the third added an output inventory, changed the formspec and added a button -- so we work out way backwards on this history and update each single case to the newest version
-- for enabling/disabling
-- so we work out way backwards on this history and update each single case
-- to the newest version
local function upgrade_autocrafter(pos, meta) local function upgrade_autocrafter(pos, meta)
local meta = meta or minetest.get_meta(pos) local meta = meta or minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -431,8 +267,7 @@ local function upgrade_autocrafter(pos, meta)
update_meta(meta, true) update_meta(meta, true)
if meta:get_string("virtual_items") == "1" then -- we are version 2 if meta:get_string("virtual_items") == "1" then -- we are version 2
-- we already dropped stuff, so lets remove the metadatasetting -- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
-- (we are not being called again for this node)
meta:set_string("virtual_items", "") meta:set_string("virtual_items", "")
else -- we are version 1 else -- we are version 1
local recipe = inv:get_list("recipe") local recipe = inv:get_list("recipe")
@ -458,7 +293,6 @@ minetest.register_node("pipeworks:autocrafter", {
drawtype = "normal", drawtype = "normal",
tiles = {"pipeworks_autocrafter.png"}, tiles = {"pipeworks_autocrafter.png"},
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1}, groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
tube = {insert_object = function(pos, node, stack, direction) tube = {insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -473,10 +307,7 @@ minetest.register_node("pipeworks:autocrafter", {
return inv:room_for_item("src", stack) return inv:room_for_item("src", stack)
end, end,
input_inventory = "dst", input_inventory = "dst",
connect_sides = { connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}},
left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1
}
},
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -487,9 +318,7 @@ minetest.register_node("pipeworks:autocrafter", {
update_meta(meta, false) update_meta(meta, false)
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if (fields.quit and not fields.key_enter_field) if (fields.quit and not fields.key_enter_field) or not pipeworks.may_configure(pos, sender) then
or not pipeworks.may_configure(pos, sender)
then
return return
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -536,9 +365,7 @@ minetest.register_node("pipeworks:autocrafter", {
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if not pipeworks.may_configure(pos, player) then if not pipeworks.may_configure(pos, player) then
minetest.log("action", string.format("%s attempted to take from " .. minetest.log("action", string.format("%s attempted to take from autocrafter at %s", player:get_player_name(), minetest.pos_to_string(pos)))
"autocrafter at %s",
player:get_player_name(), minetest.pos_to_string(pos)))
return 0 return 0
end end
upgrade_autocrafter(pos) upgrade_autocrafter(pos)
@ -554,9 +381,7 @@ minetest.register_node("pipeworks:autocrafter", {
after_inventory_change(pos) after_inventory_change(pos)
return stack:get_count() return stack:get_count()
end, end,
allow_metadata_inventory_move = function( allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
pos, from_list, from_index, to_list, to_index, count, player)
if not pipeworks.may_configure(pos, player) then return 0 end if not pipeworks.may_configure(pos, player) then return 0 end
upgrade_autocrafter(pos) upgrade_autocrafter(pos)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
@ -601,8 +426,7 @@ minetest.register_node("pipeworks:autocrafter", {
for x=1,3,1 do for x=1,3,1 do
local slot = y*3+x local slot = y*3+x
if minetest.registered_items[msg[y+1][x]] then if minetest.registered_items[msg[y+1][x]] then
inv:set_stack("recipe", slot, ItemStack( inv:set_stack("recipe",slot,ItemStack(msg[y+1][x]))
msg[y + 1][x]))
else else
inv:set_stack("recipe",slot,ItemStack("")) inv:set_stack("recipe",slot,ItemStack(""))
end end
@ -617,8 +441,7 @@ minetest.register_node("pipeworks:autocrafter", {
local row = {} local row = {}
for x=1,3,1 do for x=1,3,1 do
local slot = y*3+x local slot = y*3+x
table.insert(row, inv:get_stack( table.insert(row, inv:get_stack("recipe",slot):get_name())
"recipe", slot):get_name())
end end
table.insert(recipe, row) table.insert(recipe, row)
end end

View File

@ -3,65 +3,6 @@ Changelog
2024-02-26 (SwissalpS)
set is_ground_content to false for various nodes.
2023-06-22 (SwissalpS, rubenwardy)
groups support in recipe. Set recipe as usual via recipe formspec or digilines.
Autocrafter now resolves matching recipe using groups so that items in input
inventory are used, that match group and no longer only strictly what user
has in recipe-inventory
2023-06-21 (OgelGames, BuckarooBanzay)
fix autocrafter destroying replacement items (OG)
remove facedir debugging logs (BB)
2023-05-28 (SwissalpS)
support setting 'can_receive' for teleport tubes via digiline
2023-05-19 (fluxionary, OgelGames)
log items going through teleport tubes
2022-12-02 (wsor4035)
bring back compatibility with mineclone2
2022-11-11 (OgelGames)
prevent tp- and sand-tubes from breaking themselves and refactor part of code
2022-09-18 (fluxionary)
protection checks before break-/placeing a node -> less violation logs
2022-08-14 (wsor4035)
prevent tubes from connecting to furnace front
2022-08-13 (TurkeyMcMac)
moved teleport-tube database to mod-storage
2022-06-23 (S-S-X)
on_repair tweak, improved repairing tubes
* many updates not mentioned here *
2017-10-19 (thetaepsilon) 2017-10-19 (thetaepsilon)
Directional flowables are now implemented. Directional flowables are now implemented.
All devices for which it is relevant (valve, flow sensor etc.) have been converted so that they only flow on their connecting sides, so pressure propogation now works as expected for these devices when pressure logic is enabled. All devices for which it is relevant (valve, flow sensor etc.) have been converted so that they only flow on their connecting sides, so pressure propogation now works as expected for these devices when pressure logic is enabled.

View File

@ -1,96 +1,3 @@
local S = minetest.get_translator("pipeworks")
-- Random variables
pipeworks.expect_infinite_stacks = true
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
pipeworks.expect_infinite_stacks = false
end
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}}
pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y=0, z=0},
{x=0, y=1, z=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
{x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
{x=0, y=1, z=0}, {x=0, y=-1, z=0}}
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
pipeworks.digilines_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}}
pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end
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").."]"
-- 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
local function overlay_tube_texture(texture)
-- The texture appears the first time to be colorized as the opaque background.
return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
end
function pipeworks.make_tube_tile(tile)
if pipeworks.use_real_entities then
return tile
elseif type(tile) == "string" then
return overlay_tube_texture(tile)
else
tile = table.copy(tile)
if tile.color then
-- Won't work 100% of the time, but good enough.
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
tile.color = nil
end
tile.name = overlay_tube_texture(tile.name)
tile.backface_culling = nil -- The texture is opaque
return tile
end
end
function pipeworks.add_node_box(t, b)
if not t or not b then return end
for i in ipairs(b)
do table.insert(t, b[i])
end
end
function pipeworks.may_configure(pos, player)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and owner == name then -- wielders and filters
return true
end
return not minetest.is_protected(pos, name)
end
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)
else
ntbl[key]=i
end
end
return ntbl
end
---------------------- ----------------------
-- Vector functions -- -- Vector functions --
---------------------- ----------------------
@ -341,183 +248,6 @@ local function get_set_wrap(name, is_dynamic)
end) end)
end end
local fake_player_metatable = {
is_player = delay(true),
is_fake_player = true,
-- dummy implementation of the rest of the player API:
add_player_velocity = delay(), -- deprecated
add_velocity = delay(),
get_acceleration = delay(), -- no-op for players
get_animation = delay({x = 0, y = 0}, 0, 0, false),
get_armor_groups = delay({}),
get_attach = delay(),
get_attribute = delay(), -- deprecated
get_bone_position = delay(vector.zero(), vector.zero()),
get_children = delay({}),
get_clouds = delay({
ambient = { r = 0, b = 0, g = 0, a = 0 },
color = { r = 0, b = 0, g = 0, a = 0 },
density = 0,
height = 120,
thickness = 10,
speed = vector.zero(),
}),
get_day_night_ratio = delay(),
get_entity_name = delay(),
get_formspec_prepend = delay(""),
get_fov = delay(0, false, 0),
get_lighting = delay({
exposure = {
center_weight_power = 1,
exposure_correction = 0,
luminance_max = -3,
luminance_min = -3,
speed_bright_dark = 1000,
speed_dark_bright = 1000,
},
saturation = 1,
shadows = {
intensity = .6212,
},
}),
get_local_animation = delay({x = 0, y = 0}, {x = 0, y = 0}, {x = 0, y = 0}, {x = 0, y = 0}, 30),
get_luaentity = delay(),
get_meta = delay({
contains = delay(false),
get = delay(),
set_string = delay(),
get_string = delay(""),
set_int = delay(),
get_int = delay(0),
set_float = delay(),
get_float = delay(0),
get_keys = delay({}),
to_table = delay({fields = {}}),
from_table = delay(false),
equals = delay(false),
}),
get_moon = delay({
scale = 1,
texture = "",
tonemap = "",
visible = false,
}),
get_physics_override = delay({
acceleration_air = 1,
acceleration_default = 1,
gravity = 1,
jump = 1,
liquid_fluidity = 1,
liquid_fluidity_smooth = 1,
liquid_sink = 1,
new_move = true,
sneak = true,
sneak_glitch = false,
speed = 1,
speed_climb = 1,
speed_crouch = 1,
}),
get_player_velocity = vector.zero, -- deprecated
get_rotation = delay(), -- no-op for players
get_sky = delay({ r = 0, g = 0, b = 0, a = 0 }, "regular", {}, true),
get_sky_color = delay({
dawn_horizon = { r = 0, g = 0, b = 0, a = 0 },
dawn_sky = { r = 0, g = 0, b = 0, a = 0 },
day_horizon = { r = 0, g = 0, b = 0, a = 0 },
day_sky = { r = 0, g = 0, b = 0, a = 0 },
fog_moon_tint = { r = 0, g = 0, b = 0, a = 0 },
fog_sun_tint = { r = 0, g = 0, b = 0, a = 0 },
fog_tint_type = "default",
indoors = { r = 0, g = 0, b = 0, a = 0 },
night_horizon = { r = 0, g = 0, b = 0, a = 0 },
night_sky = { r = 0, g = 0, b = 0, a = 0 },
}),
get_stars = delay({
count = 1000,
day_opacity = 0,
scale = 1,
star_color = { r = 0, g = 0, b = 0, a = 0 },
visible = true,
}),
get_sun = delay({
scale = 1,
sunrise = "",
sunrise_visible = true,
texture = "",
tonemap = "",
visible = true,
}),
get_texture_mod = delay(), -- no-op for players
get_velocity = vector.zero,
get_yaw = delay(), -- no-op for players
getacceleration = delay(), -- backward compatibility
getvelocity = vector.zero, -- backward compatibility
getyaw = delay(), -- backward compatibility
hud_add = delay(),
hud_change = delay(),
hud_get = delay(),
hud_get_flags = delay({
basic_debug = false,
breathbar = false,
chat = false,
crosshair = false,
healthbar = false,
hotbar = false,
minimap = false,
minimap_radar = false,
wielditem = false,
}),
hud_get_hotbar_image = delay(""),
hud_get_hotbar_itemcount = delay(1),
hud_get_hotbar_selected_image = delay(""),
hud_remove = delay(),
hud_set_flags = delay(),
hud_set_hotbar_image = delay(),
hud_set_hotbar_itemcount = delay(),
hud_set_hotbar_selected_image = delay(),
override_day_night_ratio = delay(),
punch = delay(),
remove = delay(),
respawn = delay(),
right_click = delay(),
send_mapblock = delay(),
set_acceleration = delay(),
set_animation = delay(),
set_animation_frame_speed = delay(),
set_armor_groups = delay(),
set_attach = delay(),
set_attribute = delay(), -- deprecated
set_bone_position = delay(),
set_clouds = delay(),
set_detach = delay(),
set_formspec_prepend = delay(),
set_fov = delay(),
set_lighting = delay(),
set_local_animation = delay(),
set_look_horizontal = delay(),
set_look_pitch = delay(),
set_look_vertical = delay(),
set_look_yaw = delay(),
set_minimap_modes = delay(),
set_moon = delay(),
set_nametag_attributes = delay(),
set_physics_override = delay(),
set_rotation = delay(), -- no-op for players
set_sky = delay(),
set_sprite = delay(), -- no-op for players
set_stars = delay(),
set_sun = delay(),
set_texture_mod = delay(), -- no-op for players
set_velocity = delay(), -- no-op for players
set_yaw = delay(), -- no-op for players
setacceleration = delay(), -- backward compatibility
setsprite = delay(), -- backward compatibility
settexturemod = delay(), -- backward compatibility
setvelocity = delay(), -- backward compatibility
setyaw = delay(), -- backward compatibility
}
function pipeworks.create_fake_player(def, is_dynamic) function pipeworks.create_fake_player(def, is_dynamic)
local wielded_item = ItemStack("") local wielded_item = ItemStack("")
if def.inventory and def.wield_list then if def.inventory and def.wield_list then
@ -525,6 +255,8 @@ function pipeworks.create_fake_player(def, is_dynamic)
end end
local p = { local p = {
get_player_name = delay(def.name), get_player_name = delay(def.name),
is_player = delay(true),
is_fake_player = true,
_formspec = def.formspec or "", _formspec = def.formspec or "",
_hp = def.hp or 20, _hp = def.hp or 20,
@ -545,11 +277,12 @@ function pipeworks.create_fake_player(def, is_dynamic)
get_eye_offset = function(self) get_eye_offset = function(self)
return self._eye_offset1, self._eye_offset3 return self._eye_offset1, self._eye_offset3
end, end,
get_look_dir = delay(def.look_dir or vector.new()), get_look_dir = delay(def.look_dir or {x=0, y=0, z=1}),
get_look_pitch = delay(def.look_pitch or 0), get_look_pitch = delay(def.look_pitch or 0),
get_look_yaw = delay(def.look_yaw or 0), get_look_yaw = delay(def.look_yaw or 0),
get_look_horizontal = delay(def.look_yaw or 0), get_look_horizontal = delay(def.look_yaw or 0),
get_look_vertical = delay(-(def.look_pitch or 0)), get_look_vertical = delay(-(def.look_pitch or 0)),
set_animation = delay(),
-- Controls -- Controls
get_player_control = delay({ get_player_control = delay({
@ -575,11 +308,14 @@ function pipeworks.create_fake_player(def, is_dynamic)
return ItemStack(self._wielded_item) return ItemStack(self._wielded_item)
end, end,
get_wield_list = delay(def.wield_list), get_wield_list = delay(def.wield_list),
get_nametag_attributes = delay({
bgcolor = false, punch = delay(),
color = { r = 0, g = 0, b = 0, a = 0 }, remove = delay(),
text = def.name, right_click = delay(),
}), set_attach = delay(),
set_detach = delay(),
set_bone_position = delay(),
hud_change = delay(),
} }
-- Getter & setter functions -- Getter & setter functions
p.get_inventory_formspec, p.set_inventory_formspec p.get_inventory_formspec, p.set_inventory_formspec
@ -593,10 +329,37 @@ function pipeworks.create_fake_player(def, is_dynamic)
-- For players, move_to and get_pos do the same -- For players, move_to and get_pos do the same
p.move_to = p.get_pos p.move_to = p.get_pos
-- Backwards compatibility -- Backwards compatibilty
p.getpos = p.get_pos p.getpos = p.get_pos
p.setpos = p.set_pos p.setpos = p.set_pos
p.moveto = p.move_to p.moveto = p.move_to
setmetatable(p, { __index = fake_player_metatable })
-- TODO "implement" all these
-- set_armor_groups
-- get_armor_groups
-- get_animation
-- get_bone_position
-- get_player_velocity
-- set_look_pitch
-- set_look_yaw
-- set_physics_override
-- get_physics_override
-- hud_add
-- hud_remove
-- hud_get
-- hud_set_flags
-- hud_get_flags
-- hud_set_hotbar_itemcount
-- hud_get_hotbar_itemcount
-- hud_set_hotbar_image
-- hud_get_hotbar_image
-- hud_set_hotbar_selected_image
-- hud_get_hotbar_selected_image
-- hud_replace_builtin
-- set_sky
-- get_sky
-- override_day_night_ratio
-- get_day_night_ratio
-- set_local_animation
return p return p
end end

View File

@ -111,12 +111,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
minetest.after(0.2, function() minetest.after(0.2, function()
if minetest.get_modpath("default") then if minetest.get_modpath("default") then
local current_node = minetest.get_node(pos)
if current_node.name ~= "default:" .. swap .. "_open" then
-- the chest has already been replaced, don't try to replace what's there.
-- see: https://github.com/minetest/minetest_game/pull/3046
return
end
minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 }) minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
end end

View File

@ -1,5 +1,70 @@
local materials = {
stone = "default:stone",
desert_stone = "default:desert_stone",
desert_sand = "default:desert_sand",
chest = "default:chest",
copper_ingot = "default:copper_ingot",
steel_ingot = "default:steel_ingot",
gold_ingot = "default:gold_ingot",
mese = "default:mese",
mese_crystal = "default:mese_crystal",
mese_crystal_fragment = "default:mese_crystal_fragment",
teleporter = "default:mese",
glass = "default:glass",
}
if minetest.get_modpath("mcl_core") then
materials = {
stone = "mcl_core:stone",
desert_stone = "mcl_core:redsandstone",
desert_sand = "mcl_core:sand",
chest = "mcl_chests:chest",
steel_ingot = "mcl_core:iron_ingot",
gold_ingot = "mcl_core:gold_ingot",
mese = "mesecons_torch:redstoneblock",
mese_crystal = "mesecons:redstone",
mese_crystal_fragment = "mesecons:redstone",
teleporter = "mesecons_torch:redstoneblock",
copper_ingot = "mcl_copper:copper_ingot",
glass = "mcl_core:glass",
}
elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
materials = {
stone = "fl_stone:stone",
desert_stone = "fl_stone:desert_stone",
desert_sand = "fl_stone:desert_sand",
chest = "fl_storage:wood_chest",
steel_ingot = "fl_ores:iron_ingot",
gold_ingot = "fl_ores:gold_ingot",
mese = "fl_ores:iron_ingot",
mese_crystal = "fl_ores:iron_ingot",
mese_crystal_fragment = "fl_ores:iron_ingot",
teleporter = "fl_ores:iron_ingot",
copper_ingot = "fl_ores:copper_ingot",
glass = "fl_glass:framed_glass",
}
elseif minetest.get_modpath("hades_core") then
materials = {
stone = "hades_core:stone",
desert_stone = "hades_core:stone_baked",
desert_sand = "hades_core:volcanic_sand",
chest = "hades_chests:chest";
steel_ingot = "hades_core:steel_ingot",
gold_ingot = "hades_core:gold_ingot",
mese = "hades_core:mese",
mese_crystal = "hades_core:mese_crystal",
mese_crystal_fragment = "hades_core:mese_crystal_fragment",
teleporter = "hades_materials:teleporter_device",
copper_ingot = "hades_core:copper_ingot",
tin_ingot = "hades_core:tin_ingot",
glass = "hades_core:glass",
}
if minetest.get_modpath("hades_default") then
materials.desert_sand = "hades_default:desert_sand"
end
end
-- Crafting recipes for pipes -- Crafting recipes for pipes
local materials = xcompat.materials
minetest.register_craft( { minetest.register_craft( {
output = "pipeworks:pipe_1_empty 12", output = "pipeworks:pipe_1_empty 12",
@ -129,6 +194,15 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( {
output = "pipeworks:steel_block_embedded_tube 1",
recipe = {
{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
{ materials.steel_ingot, "pipeworks:tube_1", materials.steel_ingot },
{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
},
})
minetest.register_craft( { minetest.register_craft( {
output = "pipeworks:steel_pane_embedded_tube 1", output = "pipeworks:steel_pane_embedded_tube 1",
recipe = { recipe = {
@ -151,7 +225,7 @@ minetest.register_craft( {
output = "pipeworks:teleport_tube_1 2", output = "pipeworks:teleport_tube_1 2",
recipe = { recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ materials.desert_stone, materials.mese, materials.desert_stone }, { materials.desert_stone, materials.teleporter, materials.desert_stone },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
}, },
}) })
@ -223,26 +297,6 @@ if pipeworks.enable_mese_tube then
}) })
end end
if pipeworks.enable_item_tags and pipeworks.enable_tag_tube then
minetest.register_craft( {
output = "pipeworks:tag_tube_000000 2",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ materials.book, materials.mese_crystal, materials.book },
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
},
})
minetest.register_craft( {
type = "shapeless",
output = "pipeworks:tag_tube_000000",
recipe = {
"pipeworks:mese_tube_000000",
materials.book,
},
})
end
if pipeworks.enable_sand_tube then if pipeworks.enable_sand_tube then
minetest.register_craft( { minetest.register_craft( {
output = "pipeworks:sand_tube_1 2", output = "pipeworks:sand_tube_1 2",

View File

@ -1,6 +1,39 @@
local S = minetest.get_translator("pipeworks") local S = minetest.get_translator("pipeworks")
local straight = function(pos, node, velocity, stack) return {velocity} end local straight = function(pos, node, velocity, stack) return {velocity} end
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
minetest.register_node("pipeworks:steel_block_embedded_tube", {
description = S("Airtight steelblock embedded tube"),
tiles = {
steel_tex, steel_tex,
steel_tex, steel_tex,
steel_tex .. "^pipeworks_tube_connection_metallic.png",
steel_tex .. "^pipeworks_tube_connection_metallic.png",
},
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
_mcl_hardness=0.8,
legacy_facedir_simple = true,
_sound_def = {
key = "node_sound_stone_defaults",
},
tube = {
connect_sides = {front = 1, back = 1,},
priority = 50,
can_go = straight,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_dir(node.param2)
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
end,
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate,
})
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_block_embedded_tube"
local pane_box = { local pane_box = {
type = "fixed", type = "fixed",
@ -31,7 +64,6 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1}, groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
legacy_facedir_simple = true, legacy_facedir_simple = true,
_sound_def = { _sound_def = {

View File

@ -4,8 +4,6 @@ local prefix = "pipeworks_"
local settings = { local settings = {
enable_pipes = true, enable_pipes = true,
enable_item_tags = true,
enable_tag_tube = true,
enable_lowpoly = false, enable_lowpoly = false,
enable_autocrafter = true, enable_autocrafter = true,
enable_deployer = true, enable_deployer = true,

View File

@ -148,7 +148,6 @@ for s in ipairs(states) do
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = dgroups, groups = dgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -204,7 +203,6 @@ for s in ipairs(states) do
fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
}, },
groups = dgroups, groups = dgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -256,7 +254,6 @@ minetest.register_node(nodename_valve_loaded, {
fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 }
}, },
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -310,7 +307,6 @@ minetest.register_node("pipeworks:grating", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -339,7 +335,6 @@ minetest.register_node(nodename_spigot_empty, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -378,7 +373,6 @@ minetest.register_node(nodename_spigot_loaded, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -438,7 +432,6 @@ minetest.register_node(nodename_panel_empty, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -462,7 +455,6 @@ minetest.register_node(nodename_panel_loaded, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -496,7 +488,6 @@ minetest.register_node(nodename_sensor_empty, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -539,7 +530,6 @@ minetest.register_node(nodename_sensor_loaded, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -610,7 +600,6 @@ for fill = 0, 10 do
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -642,7 +631,6 @@ for fill = 0, 10 do
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = sgroups, groups = sgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -673,7 +661,6 @@ minetest.register_node(nodename_fountain_empty, {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -712,7 +699,6 @@ minetest.register_node(nodename_fountain_loaded, {
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -766,7 +752,6 @@ minetest.register_node(nodename_sp_empty, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -792,7 +777,6 @@ minetest.register_node(nodename_sp_loaded, {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",

View File

@ -14,29 +14,20 @@ local function set_filter_formspec(data, meta)
local formspec local formspec
if data.digiline then if data.digiline then
local form_height = 3
if pipeworks.enable_item_tags then
form_height = 4
end
formspec = formspec =
("size[8.5,%f]"):format(form_height) .. "size[8.5,3]"..
"item_image[0.2,0;1,1;pipeworks:"..data.name.."]".. "item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]".. "label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]".. "field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]".. "button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
fs_helpers.cycling_button(meta, ("button[0.2,%f;4.05,1"):format(form_height - 0.7), "slotseq_mode", fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode",
{S("Sequence slots by Priority"), {S("Sequence slots by Priority"),
S("Sequence slots Randomly"), S("Sequence slots Randomly"),
S("Sequence slots by Rotation")}).. S("Sequence slots by Rotation")})..
fs_helpers.cycling_button(meta, ("button[4.25,%f;4.05,1"):format(form_height - 0.7), "exmatch_mode", fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode",
{S("Exact match - off"), {S("Exact match - off"),
S("Exact match - on")}).. S("Exact match - on")})..
("button_exit[6.3,%f;2,1;close;" .. S("Close") .. "]"):format(form_height - 1.7) "button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
if pipeworks.enable_item_tags then
formspec = formspec ..
("field[0.5,%f;4.6,1;item_tags;"):format(form_height - 1.4) .. S("Item Tags") .. ";${item_tags}]" ..
("button[4.8,%f;1.5,1;set_item_tags;"):format(form_height - 1.7) .. S("Set") .. "]"
end
else else
local exmatch_button = "" local exmatch_button = ""
if data.stackwise then if data.stackwise then
@ -71,11 +62,6 @@ local function set_filter_formspec(data, meta)
exmatch_button.. exmatch_button..
pipeworks.fs_helpers.get_inv(6).. pipeworks.fs_helpers.get_inv(6)..
"listring[]" "listring[]"
if pipeworks.enable_item_tags then
formspec = formspec ..
"field[5.8,0.5;3,0.8;item_tags;" .. S("Item Tags") .. ";${item_tags}]" ..
"button[9,0.3;1,1.1;set_item_tags;" .. S("Set") .. "]"
end
end end
meta:set_string("formspec", formspec) meta:set_string("formspec", formspec)
end end
@ -137,7 +123,6 @@ local function punch_filter(data, filtpos, filtnode, msg)
local slotseq_mode local slotseq_mode
local exmatch_mode local exmatch_mode
local item_tags = pipeworks.sanitize_tags(filtmeta:get_string("item_tags"))
local filters = {} local filters = {}
if data.digiline then if data.digiline then
local function add_filter(name, group, count, wear, metadata) local function add_filter(name, group, count, wear, metadata)
@ -201,12 +186,6 @@ local function punch_filter(data, filtpos, filtnode, msg)
set_filter_formspec(data, filtmeta) set_filter_formspec(data, filtmeta)
end end
if type(msg.tags) == "table" or type(msg.tags) == "string" then
item_tags = pipeworks.sanitize_tags(msg.tags)
elseif type(msg.tag) == "string" then
item_tags = pipeworks.sanitize_tags({msg.tag})
end
if msg.nofire then if msg.nofire then
return return
end end
@ -360,7 +339,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
local pos = vector.add(frompos, vector.multiply(dir, 1.4)) local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir) local start_pos = vector.add(frompos, dir)
pipeworks.tube_inject_item(pos, start_pos, dir, item, pipeworks.tube_inject_item(pos, start_pos, dir, item,
fakePlayer:get_player_name(), item_tags) fakePlayer:get_player_name())
return true -- only fire one item, please return true -- only fire one item, please
end end
end end
@ -410,7 +389,6 @@ for _, data in ipairs({
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=1, handy=1, pickaxey=1}, groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
legacy_facedir_simple = true, legacy_facedir_simple = true,
_sound_def = { _sound_def = {
@ -478,10 +456,6 @@ for _, data in ipairs({
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if pipeworks.enable_item_tags and fields.item_tags and (fields.key_enter_field == "item_tags" or fields.set_item_tags) then
local tags = pipeworks.sanitize_tags(fields.item_tags)
meta:set_string("item_tags", table.concat(tags, ","))
end
--meta:set_int("slotseq_index", 1) --meta:set_int("slotseq_index", 1)
set_filter_formspec(data, meta) set_filter_formspec(data, meta)
set_filter_infotext(data, meta) set_filter_infotext(data, meta)
@ -503,10 +477,6 @@ for _, data in ipairs({
fs_helpers.on_receive_fields(pos, fields) fs_helpers.on_receive_fields(pos, fields)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("slotseq_index", 1) meta:set_int("slotseq_index", 1)
if pipeworks.enable_item_tags and fields.item_tags and (fields.key_enter_field == "item_tags" or fields.set_item_tags) then
local tags = pipeworks.sanitize_tags(fields.item_tags)
meta:set_string("item_tags", table.concat(tags, ","))
end
set_filter_formspec(data, meta) set_filter_formspec(data, meta)
set_filter_infotext(data, meta) set_filter_infotext(data, meta)
end end

143
init.lua
View File

@ -4,21 +4,22 @@
-- and devices that they can connect to. -- and devices that they can connect to.
-- --
pipeworks = { pipeworks = {}
ui_cat_tube_list = {}, pipeworks.ui_cat_tube_list = {}
worldpath = minetest.get_worldpath(),
modpath = minetest.get_modpath("pipeworks"), pipeworks.worldpath = minetest.get_worldpath()
liquids = { pipeworks.modpath = minetest.get_modpath("pipeworks")
water = { local S = minetest.get_translator("pipeworks")
pipeworks.liquids = {}
pipeworks.liquids.water = {
source = minetest.registered_nodes["mapgen_water_source"].name, source = minetest.registered_nodes["mapgen_water_source"].name,
flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
}, }
river_water = { pipeworks.liquids.river_water = {
source = minetest.registered_nodes["mapgen_river_water_source"].name, source = minetest.registered_nodes["mapgen_river_water_source"].name,
flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
} }
}
}
dofile(pipeworks.modpath.."/default_settings.lua") dofile(pipeworks.modpath.."/default_settings.lua")
-- Read the external config file if it exists. -- Read the external config file if it exists.
@ -35,6 +36,97 @@ if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube
minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.") minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.")
end end
-- Random variables
pipeworks.expect_infinite_stacks = true
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
pipeworks.expect_infinite_stacks = false
end
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}}
pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y=0, z=0},
{x=0, y=1, z=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
{x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
{x=0, y=1, z=0}, {x=0, y=-1, z=0}}
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
pipeworks.digilines_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}}
pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end
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").."]"
-- 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
local function overlay_tube_texture(texture)
-- The texture appears the first time to be colorized as the opaque background.
return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
end
function pipeworks.make_tube_tile(tile)
if pipeworks.use_real_entities then
return tile
elseif type(tile) == "string" then
return overlay_tube_texture(tile)
else
tile = table.copy(tile)
if tile.color then
-- Won't work 100% of the time, but good enough.
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
tile.color = nil
end
tile.name = overlay_tube_texture(tile.name)
tile.backface_culling = nil -- The texture is opaque
return tile
end
end
function pipeworks.add_node_box(t, b)
if not t or not b then return end
for i in ipairs(b)
do table.insert(t, b[i])
end
end
function pipeworks.may_configure(pos, player)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and owner == name then -- wielders and filters
return true
end
return not minetest.is_protected(pos, name)
end
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)
else
ntbl[key]=i
end
end
return ntbl
end
pipeworks.logger = function(msg) pipeworks.logger = function(msg)
minetest.log("action", "[pipeworks] "..msg) minetest.log("action", "[pipeworks] "..msg)
end end
@ -58,26 +150,14 @@ dofile(pipeworks.modpath.."/autoplace_tubes.lua")
dofile(pipeworks.modpath.."/luaentity.lua") dofile(pipeworks.modpath.."/luaentity.lua")
dofile(pipeworks.modpath.."/item_transport.lua") dofile(pipeworks.modpath.."/item_transport.lua")
dofile(pipeworks.modpath.."/flowing_logic.lua") dofile(pipeworks.modpath.."/flowing_logic.lua")
dofile(pipeworks.modpath.."/tube_registration.lua")
dofile(pipeworks.modpath.."/routing_tubes.lua")
dofile(pipeworks.modpath.."/sorting_tubes.lua")
dofile(pipeworks.modpath.."/signal_tubes.lua")
dofile(pipeworks.modpath.."/decorative_tubes.lua")
dofile(pipeworks.modpath.."/filter-injector.lua") dofile(pipeworks.modpath.."/filter-injector.lua")
dofile(pipeworks.modpath.."/trashcan.lua") dofile(pipeworks.modpath.."/trashcan.lua")
dofile(pipeworks.modpath.."/wielder.lua") dofile(pipeworks.modpath.."/wielder.lua")
dofile(pipeworks.modpath.."/tubes/registration.lua")
dofile(pipeworks.modpath.."/tubes/routing.lua")
dofile(pipeworks.modpath.."/tubes/sorting.lua")
dofile(pipeworks.modpath.."/tubes/signal.lua")
dofile(pipeworks.modpath.."/tubes/embedded_tube.lua")
dofile(pipeworks.modpath.."/tubes/pane_embedded_tube.lua")
dofile(pipeworks.modpath.."/tubes/tags.lua")
if pipeworks.enable_teleport_tube then
dofile(pipeworks.modpath.."/tubes/teleport.lua")
end
if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then
dofile(pipeworks.modpath.."/tubes/lua.lua")
end
if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then
dofile(pipeworks.modpath.."/tubes/vacuum.lua")
end
local logicdir = "/pressure_logic/" local logicdir = "/pressure_logic/"
@ -92,6 +172,9 @@ dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua")
if pipeworks.enable_pipes then if pipeworks.enable_pipes then
dofile(pipeworks.modpath.."/pipes.lua") dofile(pipeworks.modpath.."/pipes.lua")
end end
if pipeworks.enable_teleport_tube then
dofile(pipeworks.modpath.."/teleport_tube.lua")
end
if pipeworks.enable_pipe_devices then if pipeworks.enable_pipe_devices then
dofile(pipeworks.modpath.."/devices.lua") dofile(pipeworks.modpath.."/devices.lua")
end end
@ -108,6 +191,12 @@ end
if pipeworks.enable_autocrafter then if pipeworks.enable_autocrafter then
dofile(pipeworks.modpath.."/autocrafter.lua") dofile(pipeworks.modpath.."/autocrafter.lua")
end end
if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then
dofile(pipeworks.modpath.."/lua_tube.lua")
end
if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then
dofile(pipeworks.modpath.."/vacuum_tubes.lua")
end
dofile(pipeworks.modpath.."/crafts.lua") dofile(pipeworks.modpath.."/crafts.lua")

View File

@ -3,36 +3,11 @@ local enable_max_limit = minetest.settings:get_bool("pipeworks_enable_items_per_
local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30 local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
if enable_max_limit == nil then enable_max_limit = true end if enable_max_limit == nil then enable_max_limit = true end
if pipeworks.enable_item_tags then
local max_tag_length = tonumber(minetest.settings:get("pipeworks_max_item_tag_length")) or 32
local max_tags = tonumber(minetest.settings:get("pipeworks_max_item_tags")) or 16
function pipeworks.sanitize_tags(tags)
if type(tags) == "string" then
tags = tags:split(",")
end
local sanitized = {}
for i, tag in ipairs(tags) do
if type(tag) == "string" then
tag = tag:gsub("[%s,]", "") -- Remove whitespace and commas
tag = tag:gsub("%$%b%{%}", "") -- Remove special ${key} values
if tag ~= "" then
table.insert(sanitized, tag:sub(1, max_tag_length))
end
end
if #sanitized >= max_tags then
break
end
end
return sanitized
end
end
function pipeworks.tube_item(pos, item) function pipeworks.tube_item(pos, item)
error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead") error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
end end
function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags) function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner)
-- Take item in any format -- Take item in any format
local stack = ItemStack(item) local stack = ItemStack(item)
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item") local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
@ -40,7 +15,6 @@ function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags)
obj.start_pos = vector.new(start_pos) obj.start_pos = vector.new(start_pos)
obj:set_velocity(velocity) obj:set_velocity(velocity)
obj.owner = owner obj.owner = owner
obj.tags = tags
--obj:set_color("red") -- todo: this is test-only code --obj:set_color("red") -- todo: this is test-only code
return obj return obj
end end
@ -105,14 +79,13 @@ end
-- compatibility behaviour for the existing can_go() callbacks, -- compatibility behaviour for the existing can_go() callbacks,
-- which can only specify a list of possible positions. -- which can only specify a list of possible positions.
local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, tags) local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
local next_positions = {} local next_positions = {}
local max_priority = 0 local max_priority = 0
local can_go local can_go
local def = minetest.registered_nodes[cnode.name] if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
if def and def.tube and def.tube.can_go then can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
can_go = def.tube.can_go(pos, cnode, vel, stack, tags)
else else
local adjlist_string = minetest.get_meta(pos):get_string("adjlist") 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 local adjlist = minetest.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
@ -171,7 +144,7 @@ end
-- * a "multi-mode" data table (or nil if N/A) where a stack was split apart. -- * a "multi-mode" data table (or nil if N/A) where a stack was split apart.
-- if this is not nil, the luaentity spawns new tubed items for each new fragment stack, -- if this is not nil, the luaentity spawns new tubed items for each new fragment stack,
-- then deletes itself (i.e. the original item stack). -- then deletes itself (i.e. the original item stack).
local function go_next(pos, velocity, stack, owner, tags) local function go_next(pos, velocity, stack, owner)
local cnode = minetest.get_node(pos) local cnode = minetest.get_node(pos)
local cmeta = minetest.get_meta(pos) local cmeta = minetest.get_meta(pos)
local speed = math.abs(velocity.x + velocity.y + velocity.z) local speed = math.abs(velocity.x + velocity.y + velocity.z)
@ -199,7 +172,7 @@ local function go_next(pos, velocity, stack, owner, tags)
-- n is the new value of the cycle counter. -- n is the new value of the cycle counter.
-- XXX: this probably needs cleaning up after being split out, -- XXX: this probably needs cleaning up after being split out,
-- seven args is a bit too many -- seven args is a bit too many
local n, found, new_velocity, multimode = go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, tags) local n, found, new_velocity, multimode = go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
-- if not using output cycling, -- if not using output cycling,
-- don't update the field so it stays the same for the next item. -- don't update the field so it stays the same for the next item.
@ -303,7 +276,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
color_entity = nil, color_entity = nil,
color = nil, color = nil,
start_pos = nil, start_pos = nil,
tags = nil,
set_item = function(self, item) set_item = function(self, item)
local itemstring = ItemStack(item):to_string() -- Accept any input format local itemstring = ItemStack(item):to_string() -- Accept any input format
@ -365,9 +337,8 @@ luaentity.register_entity("pipeworks:tubed_item", {
local node = minetest.get_node(self.start_pos) local node = minetest.get_node(self.start_pos)
if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
local leftover local leftover
local def = minetest.registered_nodes[node.name] if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
if def.tube and def.tube.insert_object then leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
leftover = def.tube.insert_object(self.start_pos, node, stack, vel, self.owner)
else else
leftover = stack leftover = stack
end end
@ -382,14 +353,7 @@ luaentity.register_entity("pipeworks:tubed_item", {
return return
end end
local tags local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
if pipeworks.enable_item_tags then
tags = self.tags or {}
end
local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner, tags) -- todo: color
if pipeworks.enable_item_tags then
self.tags = #tags > 0 and tags or nil
end
local rev_vel = vector.multiply(velocity, -1) local rev_vel = vector.multiply(velocity, -1)
local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel)) local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir))) local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))

View File

@ -24,7 +24,7 @@ if not minetest.get_modpath("auto_tree_tap") and
description = S("Auto-Tap"), description = S("Auto-Tap"),
tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png", 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"}, "pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
is_ground_content = false, is_ground_content = true,
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=1, handy=1, pickaxey=1}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=1, handy=1, pickaxey=1},
_mcl_hardness=0.8, _mcl_hardness=0.8,

View File

@ -370,10 +370,7 @@ local function clean_and_weigh_digiline_message(msg, back_references)
return msg, #msg + 25 return msg, #msg + 25
elseif t == "number" then elseif t == "number" then
-- Numbers are passed by value so need not be touched, and cost 8 bytes -- Numbers are passed by value so need not be touched, and cost 8 bytes
-- as all numbers in Lua are doubles. NaN values are removed. -- as all numbers in Lua are doubles.
if msg ~= msg then
return nil, 0
end
return msg, 8 return msg, 8
elseif t == "boolean" then elseif t == "boolean" then
-- Booleans are passed by value so need not be touched, and cost 1 -- Booleans are passed by value so need not be touched, and cost 1
@ -948,7 +945,7 @@ for white = 0, 1 do
tube = { tube = {
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}, connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
priority = 50, priority = 50,
can_go = function(pos, node, velocity, stack, tags) can_go = function(pos, node, velocity, stack)
local src = {name = nil} local src = {name = nil}
-- add color of the incoming tube explicitly; referring to rules, in case they change later -- add color of the incoming tube explicitly; referring to rules, in case they change later
for _, rule in pairs(rules) do for _, rule in pairs(rules) do
@ -963,33 +960,12 @@ for white = 0, 1 do
itemstring = stack:to_string(), itemstring = stack:to_string(),
item = stack:to_table(), item = stack:to_table(),
velocity = velocity, velocity = velocity,
tags = table.copy(tags),
side = src.name,
}) })
if not succ then if not succ or type(msg) ~= "string" then
return go_back(velocity) return go_back(velocity)
end end
if type(msg) == "string" then local r = rules[msg]
local side = rules[msg] return r and {r} or go_back(velocity)
return side and {side} or go_back(velocity)
elseif type(msg) == "table" then
if pipeworks.enable_item_tags then
local new_tags
if type(msg.tags) == "table" or type(msg.tags) == "string" then
new_tags = pipeworks.sanitize_tags(msg.tags)
elseif type(msg.tag) == "string" then
new_tags = pipeworks.sanitize_tags({msg.tag})
end
if new_tags then
for i=1, math.max(#tags, #new_tags) do
tags[i] = new_tags[i]
end
end
end
local side = rules[msg.side]
return side and {side} or go_back(velocity)
end
return go_back(velocity)
end, end,
}, },
after_place_node = pipeworks.after_place, after_place_node = pipeworks.after_place,

View File

@ -1,5 +1,5 @@
name = pipeworks 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. 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 = basic_materials, xcompat depends = basic_materials
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience
min_minetest_version = 5.5.0 min_minetest_version = 5.4.0

View File

@ -76,7 +76,6 @@ for index, connects in ipairs(cconnects) do
fixed = outsel fixed = outsel
}, },
groups = pgroups, groups = pgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -114,7 +113,6 @@ for index, connects in ipairs(cconnects) do
fixed = outsel fixed = outsel
}, },
groups = pgroups, groups = pgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_metal_defaults", key = "node_sound_metal_defaults",
@ -153,7 +151,6 @@ if REGISTER_COMPATIBILITY then
paramtype = "light", paramtype = "light",
description = S("Pipe Segment (legacy)"), description = S("Pipe Segment (legacy)"),
groups = {not_in_creative_inventory = 1, pipe_to_update = 1}, groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
is_ground_content = false,
drop = "pipeworks:pipe_1_empty", drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos) after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos) pipeworks.scan_for_pipe_objects(pos)
@ -166,7 +163,6 @@ if REGISTER_COMPATIBILITY then
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
groups = {not_in_creative_inventory = 1, pipe_to_update = 1}, groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
is_ground_content = false,
drop = "pipeworks:pipe_1_empty", drop = "pipeworks:pipe_1_empty",
after_place_node = function(pos) after_place_node = function(pos)
pipeworks.scan_for_pipe_objects(pos) pipeworks.scan_for_pipe_objects(pos)

View File

@ -50,7 +50,6 @@ pipeworks.register_tube("pipeworks:broken_tube", {
node_def = { node_def = {
drop = "pipeworks:tube_1", drop = "pipeworks:tube_1",
groups = {not_in_creative_inventory = 1, tubedevice_receiver = 1}, groups = {not_in_creative_inventory = 1, tubedevice_receiver = 1},
is_ground_content = false,
tube = { tube = {
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
minetest.item_drop(stack, nil, pos) minetest.item_drop(stack, nil, pos)
@ -94,7 +93,6 @@ pipeworks.register_tube("pipeworks:broken_tube", {
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 }) minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
pipeworks.scan_for_tube_objects(pos) pipeworks.scan_for_tube_objects(pos)
end end
meta:set_string("the_tube_was", "")
else else
pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.") pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
minetest.chat_send_player(playername, S("This tube cannot be repaired.")) minetest.chat_send_player(playername, S("This tube cannot be repaired."))
@ -180,7 +178,6 @@ if pipeworks.enable_one_way_tube then
node_box = {type = "fixed", node_box = {type = "fixed",
fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}}, fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1}, groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_wood_defaults", key = "node_sound_wood_defaults",

View File

@ -357,7 +357,6 @@ pipeworks.tptube = {
hash = hash_pos, hash = hash_pos,
get_db = function() return tube_db end, get_db = function() return tube_db end,
save_tube_db = save_tube_db, save_tube_db = save_tube_db,
remove_tube = remove_tube,
set_tube = set_tube, set_tube = set_tube,
save_tube = save_tube, save_tube = save_tube,
update_tube = update_tube, update_tube = update_tube,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

View File

@ -11,7 +11,6 @@ minetest.register_node("pipeworks:trashcan", {
"pipeworks_trashcan_side.png", "pipeworks_trashcan_side.png",
}, },
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1},
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
tube = { tube = {
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)

View File

@ -106,7 +106,6 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
fixed = outboxes fixed = outboxes
}, },
groups = tgroups, groups = tgroups,
is_ground_content = false,
_mcl_hardness=0.8, _mcl_hardness=0.8,
_sound_def = { _sound_def = {
key = "node_sound_wood_defaults", key = "node_sound_wood_defaults",
@ -228,7 +227,6 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
description = S("Pneumatic tube segment (legacy)"), description = S("Pneumatic tube segment (legacy)"),
after_place_node = pipeworks.after_place, after_place_node = pipeworks.after_place,
groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1}, groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
is_ground_content = false,
tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}}, tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}},
drop = name.."_1", drop = name.."_1",
}) })

View File

@ -1,69 +0,0 @@
local materials = xcompat.materials
local S = minetest.get_translator("pipeworks")
local straight = function(pos, node, velocity, stack) return {velocity} end
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
-- register an embedded tube
function pipeworks.register_embedded_tube(nodename, opts)
minetest.register_node(nodename, {
description = opts.description,
tiles = {
opts.base_texture,
opts.base_texture,
opts.base_texture,
opts.base_texture,
opts.base_texture .. "^pipeworks_tube_connection_metallic.png",
opts.base_texture .. "^pipeworks_tube_connection_metallic.png",
},
paramtype = "light",
paramtype2 = "facedir",
groups = {
cracky = 1,
oddly_breakable_by_hand = 1,
tubedevice = 1,
dig_glass = 2,
pickaxey=1,
handy=1
},
is_ground_content = false,
_mcl_hardness = 0.8,
legacy_facedir_simple = true,
_sound_def = {
key = "node_sound_stone_defaults",
},
tube = {
connect_sides = {
front = 1,
back = 1
},
priority = 50,
can_go = straight,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_dir(node.param2)
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
end
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate,
})
minetest.register_craft( {
output = nodename .. " 1",
recipe = {
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient },
{ opts.base_ingredient, "pipeworks:tube_1", opts.base_ingredient },
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient }
},
})
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = nodename
end
-- steelblock embedded tube
pipeworks.register_embedded_tube("pipeworks:steel_block_embedded_tube", {
description = S("Airtight steelblock embedded tube"),
base_texture = steel_tex,
base_ingredient = materials.steel_ingot
})

View File

@ -1,139 +0,0 @@
local S = minetest.get_translator("pipeworks")
local fs_helpers = pipeworks.fs_helpers
if not pipeworks.enable_item_tags or not pipeworks.enable_tag_tube then return end
local help_text = minetest.formspec_escape(
S("Separate multiple tags using commas.").."\n"..
S("Use \"<none>\" to match items without tags.")
)
local update_formspec = function(pos)
local meta = minetest.get_meta(pos)
local buttons_formspec = ""
for i = 0, 5 do
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
"image_button[9," .. (i + (i * 0.25) + 0.5) .. ";1,0.6", "l" .. (i + 1) .. "s",
{
pipeworks.button_off,
pipeworks.button_on
}
)
end
local size = "10.2,9"
meta:set_string("formspec",
"formspec_version[2]" ..
"size[" .. size .. "]" ..
pipeworks.fs_helpers.get_prepends(size) ..
"field[1.5,0.25;7.25,1;tags1;;${tags1}]" ..
"field[1.5,1.5;7.25,1;tags2;;${tags2}]" ..
"field[1.5,2.75;7.25,1;tags3;;${tags3}]" ..
"field[1.5,4.0;7.25,1;tags4;;${tags4}]" ..
"field[1.5,5.25;7.25,1;tags5;;${tags5}]" ..
"field[1.5,6.5;7.25,1;tags6;;${tags6}]" ..
"image[0.22,0.25;1,1;pipeworks_white.png]" ..
"image[0.22,1.50;1,1;pipeworks_black.png]" ..
"image[0.22,2.75;1,1;pipeworks_green.png]" ..
"image[0.22,4.00;1,1;pipeworks_yellow.png]" ..
"image[0.22,5.25;1,1;pipeworks_blue.png]" ..
"image[0.22,6.50;1,1;pipeworks_red.png]" ..
buttons_formspec ..
"label[0.22,7.9;"..help_text.."]"..
"button[7.25,7.8;1.5,0.8;set_item_tags;" .. S("Set") .. "]"
)
end
pipeworks.register_tube("pipeworks:tag_tube", {
description = S("Tag Sorting Pneumatic Tube Segment"),
inventory_image = "pipeworks_tag_tube_inv.png",
noctr = { "pipeworks_tag_tube_noctr_1.png", "pipeworks_tag_tube_noctr_2.png", "pipeworks_tag_tube_noctr_3.png",
"pipeworks_tag_tube_noctr_4.png", "pipeworks_tag_tube_noctr_5.png", "pipeworks_tag_tube_noctr_6.png" },
plain = { "pipeworks_tag_tube_plain_1.png", "pipeworks_tag_tube_plain_2.png", "pipeworks_tag_tube_plain_3.png",
"pipeworks_tag_tube_plain_4.png", "pipeworks_tag_tube_plain_5.png", "pipeworks_tag_tube_plain_6.png" },
ends = { "pipeworks_tag_tube_end.png" },
short = "pipeworks_tag_tube_short.png",
no_facedir = true, -- Must use old tubes, since the textures are rotated with 6d ones
node_def = {
tube = {
can_go = function(pos, node, velocity, stack, tags)
local tbl, tbln = {}, 0
local found, foundn = {}, 0
local meta = minetest.get_meta(pos)
local tag_hash = {}
if #tags > 0 then
for _,tag in ipairs(tags) do
tag_hash[tag] = true
end
else
tag_hash["<none>"] = true -- Matches items without tags
end
for i, vect in ipairs(pipeworks.meseadjlist) do
local npos = vector.add(pos, vect)
local node = minetest.get_node(npos)
local reg_node = minetest.registered_nodes[node.name]
if meta:get_int("l" .. i .. "s") == 1 and reg_node then
local tube_def = reg_node.tube
if not tube_def or not tube_def.can_insert or
tube_def.can_insert(npos, node, stack, vect) then
local side_tags = meta:get_string("tags" .. i)
if side_tags ~= "" then
side_tags = pipeworks.sanitize_tags(side_tags)
for _,tag in ipairs(side_tags) do
if tag_hash[tag] then
foundn = foundn + 1
found[foundn] = vect
break
end
end
else
tbln = tbln + 1
tbl[tbln] = vect
end
end
end
end
return (foundn > 0) and found or tbl
end
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
for i = 1, 6 do
meta:set_int("l" .. tostring(i) .. "s", 1)
end
update_formspec(pos)
meta:set_string("infotext", S("Tag sorting pneumatic tube"))
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
if placer and placer:is_player() and placer:get_player_control().aux1 then
local meta = minetest.get_meta(pos)
for i = 1, 6 do
meta:set_int("l" .. tostring(i) .. "s", 0)
end
update_formspec(pos)
end
return pipeworks.after_place(pos, placer, itemstack, pointed_thing)
end,
on_receive_fields = function(pos, formname, fields, sender)
if (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
for i = 1, 6 do
local field_name = "tags" .. tostring(i)
if fields[field_name] then
local tags = pipeworks.sanitize_tags(fields[field_name])
meta:set_string(field_name, table.concat(tags, ","))
end
end
fs_helpers.on_receive_fields(pos, fields)
update_formspec(pos)
end,
can_dig = function(pos, player)
return true
end,
},
})

View File

@ -32,12 +32,6 @@ local function set_timer(pos)
timer:start(math.random(10, 20) * 0.1) timer:start(math.random(10, 20) * 0.1)
end end
local function repair_tube(pos, was_node)
minetest.swap_node(pos, {name = was_node.name, param2 = was_node.param2})
pipeworks.scan_for_tube_objects(pos)
set_timer(pos)
end
if pipeworks.enable_sand_tube then if pipeworks.enable_sand_tube then
pipeworks.register_tube("pipeworks:sand_tube", { pipeworks.register_tube("pipeworks:sand_tube", {
description = S("Vacuuming Pneumatic Tube Segment"), description = S("Vacuuming Pneumatic Tube Segment"),
@ -48,9 +42,6 @@ if pipeworks.enable_sand_tube then
ends = {"pipeworks_sand_tube_end.png"}, ends = {"pipeworks_sand_tube_end.png"},
node_def = { node_def = {
groups = {vacuum_tube = 1}, groups = {vacuum_tube = 1},
tube = {
on_repair = repair_tube,
},
on_construct = set_timer, on_construct = set_timer,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
vacuum(pos, 2) vacuum(pos, 2)
@ -77,9 +68,6 @@ if pipeworks.enable_mese_sand_tube then
ends = {"pipeworks_mese_sand_tube_end.png"}, ends = {"pipeworks_mese_sand_tube_end.png"},
node_def = { node_def = {
groups = {vacuum_tube = 1}, groups = {vacuum_tube = 1},
tube = {
on_repair = repair_tube,
},
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("dist", 2) meta:set_int("dist", 2)

View File

@ -195,7 +195,7 @@ local function register_wielder(data)
return stack:get_count() return stack:get_count()
end, end,
}, },
is_ground_content = false, is_ground_content = true,
paramtype2 = "facedir", paramtype2 = "facedir",
tubelike = 1, tubelike = 1,
groups = groups, groups = groups,