16 Commits

Author SHA1 Message Date
3a01f3f8ca fix chest duplication bug
closes #118
2024-03-17 20:06:35 +01:00
1577af738f Autocrafter multi group ingredient (#115)
* check for non-zero group value

in theory groups can have negative values too.

* fix #114 multi group recipe items

Fix the bug that prevented crafting with recipes
that had ingredients that need to match multiple
groups.

* comments and whitespace changes

* fix faulty empty table check
2024-03-13 17:31:38 +01:00
8828183bef remove nan values from digiline messages 2024-03-12 14:17:29 +11:00
ce263da6d5 also accept strings of tags in digilines and lua
fixes #116
2024-03-07 14:56:19 +11:00
6c66a2f43c Tags support (#107)
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Co-authored-by: Slava Zanko <slava.zanko@godel.shellenergy.co.uk>
Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
Co-authored-by: OgelGames <olliverdc28@gmail.com>
2024-03-03 22:48:27 +11:00
8724c28939 switch to using xcompat (#113) 2024-03-03 12:37:46 +01:00
cb2a59131c Make wielder nodes not ground content (#112)
nodebreaker, deployer and dispenser
2024-03-03 14:52:23 +13:00
c7b153f1ef Is ground content (#110)
* trashcan isn't ground content

* pipes aren't ground content

* auto tree tap isn't ground content

* filter-injectors aren't ground content

* devices aren't ground content

also some whitespace indentation fixes

* is_ground_content

* autocrafter isn't ground content

* tubes aren't ground content

* pane_embedded_tube isn't ground content

* embedded_tube isn't ground content

* routing tubes aren't ground content

* whitespace fix indentation
2024-02-26 18:44:40 -05:00
96dca7e540 Fix autocrafter crafting bug (#108) 2024-02-08 21:01:54 +11:00
c87522c526 export pipeworks.tptube.remove_tube (#105)
Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2024-01-28 16:08:24 -05:00
6d824a318a Tube repair fixes (#102)
* restart vacuum tube node timers after repair

* clear metadata value after repair
2024-01-14 10:10:24 +01:00
04df87a6c2 Delete .editorconfig 2024-01-14 14:29:55 +11:00
360ed9bdde Autocrafter groups support (#74)
* Add support for recipes with groups to autocrafter

* fix autocrafter replacements

* remove unnecessary check and move some code

* reorder and change back var name

* only whitespace changes

* reuse hash that is asigned to variable anyway

* add get_matching_craft

function that looks for the best matching recipe according to what user
put in recipe inventory

some crafts use groups in multiple recipes

* return right away if there is a chached craft

gives us more horizontal space to work with

* indentation adjusting

* use get_matching_craft to get best craft

this line was buggy anyhow

* new craft format: decremented_input

craft.decremented_input now only holds the items. Extra parameters are
dropped

* bugfix: when item has no groups

"" and unknown items have no def and thus no groups

* add function has_room_for_output

moving the output space calculation into its own function
helps keep autocraft() short and overseeable

* use has_room_for_output

* remove double-check of available materials

* add warning to ensure double-check was not needed

* rebuild cache whenever recipe inv changes

no need to check if still current, this only happens when user is
interacting and can only be better to do so.
Otherwise we would have to check groups etc. again just to check, so
might as well reset cache.

* remove unused line

* use minetest.get_item_group()

* whitespace cleanup

make code easier to read and give it a more
"thoughtthrough" look than the "smash it in to make it work" look it has
had.

(I'm holding back, there would be more to do overall through this mod)

* add .editorconfig

this should also help keep consistency throughout this mod

* changelog updated

at least the most recent more important ones

* whitespace changelog (trailing spaces)

---------

Co-authored-by: rubenwardy <rw@rubenwardy.com>
Co-authored-by: OgelGames <olliverdc28@gmail.com>
Co-authored-by: wsor4035 <24964441+wsor4035@users.noreply.github.com>
2024-01-13 20:41:28 -05:00
578e45257b code and registrations cleanup (#101)
* code and registrations cleanup

* don't expose materials to global env

---------

Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2024-01-13 20:40:01 -05:00
dd6950f7b0 bump min_minetest_version to 5.5.0 for vector.zero()
closes #100
2024-01-05 16:11:23 +11:00
5b0dceb44a add dummy implementations of all current API calls to fake player (#98)
* add dummy implementations of all current API calls to fake player

* fakeplayer: move all stateless API into a metatable

* correctly set metatable
2023-12-29 14:01:08 -05:00
42 changed files with 1120 additions and 476 deletions

View File

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

View File

@ -20,6 +20,7 @@ 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,11 +1,15 @@
local S = minetest.get_translator("pipeworks") 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 -- cache some recipe data to avoid calling the slow function
-- 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()
@ -21,41 +25,177 @@ 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 not craft then if craft then return craft end
local recipe = inventory:get_list("recipe")
local output, decremented_input = minetest.get_craft_result({method = "normal", width = 3, items = recipe}) local example_recipe = inventory:get_list("recipe")
craft = {recipe = recipe, consumption=count_index(recipe), output = output, decremented_input = decremented_input} local output, decremented_input = minetest.get_craft_result({
autocrafterCache[hash] = craft 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 end
craft = {
recipe = recipe,
consumption = count_index(recipe),
output = output,
decremented_input = decremented_input.items
}
autocrafterCache[hash] = craft
return craft return craft
end end
local function autocraft(inventory, craft) -- From a consumption table with groups and an inventory index,
if not craft then return false end -- build a consumption table without groups
-- check if we have enough material available local function calculate_consumption(inv_index, consumption_with_groups)
local inv_index = count_index(inventory:get_list("src")) inv_index = table.copy(inv_index)
for itemname, number in pairs(craft.consumption) do consumption_with_groups = table.copy(consumption_with_groups)
if (not inv_index[itemname]) or inv_index[itemname] < number then return false end
end -- table of items to actually consume
-- check if output and all replacements fit in dst local consumption = {}
local output = craft.output.item -- table of ingredients defined as one or more groups each
local out_items = count_index(craft.decremented_input.items) local grouped_ingredients = {}
out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count()
local empty_count = 0 -- First consume all non-group requirements
for _,item in pairs(inventory:get_list("dst")) do -- This is done to avoid consuming a non-group item which
if item:is_empty() then -- is also in a group
empty_count = empty_count + 1 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 else
local name = item:get_name() -- if the item to consume doesn't exist in inventory
if out_items[name] then -- or not enough of them, abort crafting
out_items[name] = out_items[name] - item:get_free_space() if not inv_index[key] or inv_index[key] < count then
return nil
end
consumption[key] = (consumption[key] or 0) + count
consumption_with_groups[key] = consumption_with_groups[key] - count
assert(consumption_with_groups[key] == 0)
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 end
end end
for _,count in pairs(out_items) do
-- 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
for _, item in pairs(list_output) do
if item:is_empty() then
empty_count = empty_count + 1
else
name = item:get_name()
if index_output[name] then
index_output[name] = index_output[name] - item:get_free_space()
end
end
end
for _, count in pairs(index_output) do
if count > 0 then if count > 0 then
empty_count = empty_count - 1 empty_count = empty_count - 1
end end
@ -63,22 +203,54 @@ local function autocraft(inventory, craft)
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(craft.consumption) do for itemname, number in pairs(consumption) do
for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max -- 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
inventory:add_item("dst", craft.decremented_input.items[i]) leftover = inventory:add_item("dst", craft.decremented_input[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 cached recipe -- is started only from start_autocrafter(pos) after sanity checks and
-- 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()
@ -90,7 +262,7 @@ local function run_autocrafter(pos, elapsed)
return false return false
end end
for _ = 1, math.floor(elapsed/craft_time) do for _ = 1, math.floor(elapsed / craft_time) do
local continue = autocraft(inventory, craft) local continue = autocraft(inventory, craft)
if not continue then return false end if not continue then return false end
end end
@ -114,33 +286,17 @@ 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 recipe = inventory:get_list("recipe") local craft = get_craft(pos, inventory, hash)
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))
@ -149,7 +305,8 @@ 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 items in the crafting grid -- clean out unknown items and groups, which would be handled like unknown
-- 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)
@ -180,58 +337,65 @@ 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 result of the new recipe -- we'll set the output slot in after_recipe_change to the actual
-- 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 after this -- returns false if we shouldn't bother attempting to start the timer again
-- 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)
local list_backgrounds = "" local list_backgrounds = ""
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
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[".. 0.22+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]" list_backgrounds = list_backgrounds .. "box[" ..
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[".. 5.28+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]" list_backgrounds = list_backgrounds .. "box[" ..
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[".. 0.22+(i*1.25) ..",".. 5+(j*1.25) ..";1,1;]" list_backgrounds = list_backgrounds .. "box[" ..
0.22 + (i * 1.25) .. "," .. 5 + (j * 1.25) .. ";1,1;]"
end end
end end
end end
local size = "10.2,14" local size = "10.2,14"
local fs = local fs =
"formspec_version[2]".. "formspec_version[2]" ..
"size["..size.."]".. "size[" .. size .. "]" ..
pipeworks.fs_helpers.get_prepends(size).. pipeworks.fs_helpers.get_prepends(size) ..
list_backgrounds.. list_backgrounds ..
"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;" .. state .. ";;;false;pipeworks_button_interm.png]" .. "image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" ..
"list[context;dst;5.28,0.22;4,3;]".. state .. ";;;false;pipeworks_button_interm.png]" ..
"list[context;src;0.22,5;8,3;]".. "list[context;dst;5.28,0.22;4,3;]" ..
pipeworks.fs_helpers.get_inv(9).. "list[context;src;0.22,5;8,3;]" ..
"listring[current_player;main]".. pipeworks.fs_helpers.get_inv(9) ..
"listring[current_player;main]" ..
"listring[context;src]" .. "listring[context;src]" ..
"listring[current_player;main]".. "listring[current_player;main]" ..
"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")..";${channel}]".. fs = fs .. "field[0.22,4.1;4.5,0.75;channel;" .. S("Channel") ..
"button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]".. ";${channel}]" ..
"button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]" "button[5,4.1;1.5,0.75;set_channel;" .. S("Set") .. "]" ..
"button_exit[6.8,4.1;2,0.75;close;" .. S("Close") .. "]"
end end
meta:set_string("formspec",fs) meta:set_string("formspec", fs)
-- toggling the button doesn't quite call for running a recipe change check -- toggling the button doesn't quite call for running a recipe change check
-- so instead we run a minimal version for infotext setting only -- so instead we run a minimal version for infotext setting only
@ -251,9 +415,12 @@ 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 set "virtual_items" to string "1" -- the 2nd replaced these with virtual items, dropped the content on update and
-- the third added an output inventory, changed the formspec and added a button for enabling/disabling -- set "virtual_items" to string "1"
-- so we work out way backwards on this history and update each single case to the newest version -- the third added an output inventory, changed the formspec and added a button
-- 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()
@ -264,7 +431,8 @@ 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 are not being called again for this node) -- we already dropped stuff, so lets remove the metadatasetting
-- (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")
@ -290,6 +458,7 @@ 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)
@ -304,18 +473,23 @@ 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 = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}}, connect_sides = {
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()
inv:set_size("src", 3*8) inv:set_size("src", 3 * 8)
inv:set_size("recipe", 3*3) inv:set_size("recipe", 3 * 3)
inv:set_size("dst", 4*3) inv:set_size("dst", 4 * 3)
inv:set_size("output", 1) inv:set_size("output", 1)
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) or not pipeworks.may_configure(pos, sender) then if (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender)
then
return return
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -362,7 +536,9 @@ 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 autocrafter at %s", player:get_player_name(), minetest.pos_to_string(pos))) minetest.log("action", string.format("%s attempted to take from " ..
"autocrafter at %s",
player:get_player_name(), minetest.pos_to_string(pos)))
return 0 return 0
end end
upgrade_autocrafter(pos) upgrade_autocrafter(pos)
@ -378,7 +554,9 @@ 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(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(
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()
@ -419,13 +597,14 @@ minetest.register_node("pipeworks:autocrafter", {
if type(msg) == "table" then if type(msg) == "table" then
if #msg < 3 then return end if #msg < 3 then return end
local inv = meta:get_inventory() local inv = meta:get_inventory()
for y=0,2,1 do for y = 0, 2, 1 do
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(msg[y+1][x])) inv:set_stack("recipe", slot, ItemStack(
msg[y + 1][x]))
else else
inv:set_stack("recipe",slot,ItemStack("")) inv:set_stack("recipe", slot, ItemStack(""))
end end
end end
end end
@ -434,11 +613,12 @@ minetest.register_node("pipeworks:autocrafter", {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local recipe = {} local recipe = {}
for y=0,2,1 do for y = 0, 2, 1 do
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("recipe",slot):get_name()) table.insert(row, inv:get_stack(
"recipe", slot):get_name())
end end
table.insert(recipe, row) table.insert(recipe, row)
end end
@ -465,4 +645,4 @@ minetest.register_node("pipeworks:autocrafter", {
}, },
}, },
}) })
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:autocrafter" pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list + 1] = "pipeworks:autocrafter"

View File

@ -3,6 +3,65 @@ 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.
@ -50,91 +109,91 @@ What *does not* work:
*seems this hasn't been updated in a while* *seems this hasn't been updated in a while*
2013-01-13: Tubes can transport items now! Namely, I added Novatux/Nore's item 2013-01-13: Tubes can transport items now! Namely, I added Novatux/Nore's item
transport mod as a default part of this mod, to make tubes do something useful! transport mod as a default part of this mod, to make tubes do something useful!
Thanks to Nore and RealBadAngel for the code contributions! Thanks to Nore and RealBadAngel for the code contributions!
2013-01-05: made storage tanks connect from top/bottom, made storage tank and 2013-01-05: made storage tanks connect from top/bottom, made storage tank and
pipe textures use the ^ combine operator so they can show the actual liquid pipe textures use the ^ combine operator so they can show the actual liquid
going through the pipes/tanks. going through the pipes/tanks.
2013-01-04 (a bit later): Made pipes able to carry water! It was just a minor 2013-01-04 (a bit later): Made pipes able to carry water! It was just a minor
logic error resulting from moving the water flowing code into it's own file logic error resulting from moving the water flowing code into it's own file
when I originally imported it. Many thanks to Mauvebic for writing it! when I originally imported it. Many thanks to Mauvebic for writing it!
2013-01-04: First stage of integrating Mauvebic's water flowing code. This is 2013-01-04: First stage of integrating Mauvebic's water flowing code. This is
experimental and doesn't move water yet - but at least it doesn't break experimental and doesn't move water yet - but at least it doesn't break
anything :-) anything :-)
2013-01-01: Various minor tweaks to textures, facedir settings, some other 2013-01-01: Various minor tweaks to textures, facedir settings, some other
stuff. Changed crafting recipes to account for revamped pumps, valves, etc. stuff. Changed crafting recipes to account for revamped pumps, valves, etc.
Now requires the moreores mod and most recent git (for mese crystal fragments) Now requires the moreores mod and most recent git (for mese crystal fragments)
to craft a pump. Added a "sealed" entry/exit panel (really just a horizontal to craft a pump. Added a "sealed" entry/exit panel (really just a horizontal
pipe with a metal panel overlayed into the middle). Also, tweaked pipes to pipe with a metal panel overlayed into the middle). Also, tweaked pipes to
always drop the empty ones. Revamped pumps so that now they should sit in/on always drop the empty ones. Revamped pumps so that now they should sit in/on
liquid and be connected only from the top, relegated grates to decorational- liquid and be connected only from the top, relegated grates to decorational-
only, added outlet spigot. Got rid of a few obsolete textures. Got rid of only, added outlet spigot. Got rid of a few obsolete textures. Got rid of
that whole _x and _z naming thing - now all directional devices (pumps, valves, that whole _x and _z naming thing - now all directional devices (pumps, valves,
spigots, tanks) use facedir. Valves, spigots no longer auto-rotate to find spigots, tanks) use facedir. Valves, spigots no longer auto-rotate to find
nearby pipes. nearby pipes.
2012-09-17: Added test object for pneumatic tube autorouting code, made tubes 2012-09-17: Added test object for pneumatic tube autorouting code, made tubes
connect to it and any object that bears groups={tubedevice=1} (connects to any connect to it and any object that bears groups={tubedevice=1} (connects to any
side) side)
2012-09-05: All recipes doubled except for junglegrass -> plastic sheet (since 2012-09-05: All recipes doubled except for junglegrass -> plastic sheet (since
that is derived from home decor) that is derived from home decor)
2012-09-02: Fixed plastic sheeting recipe. Added crafting recipes for various 2012-09-02: Fixed plastic sheeting recipe. Added crafting recipes for various
objects, with options: If homedecor is installed, use the plastic sheeting objects, with options: If homedecor is installed, use the plastic sheeting
therein. If not, we define it manually. If the Technic mod is installed, therein. If not, we define it manually. If the Technic mod is installed,
don't define any recipes at all. Also removed the extra "loaded!" messages and don't define any recipes at all. Also removed the extra "loaded!" messages and
tweaked the default pipe alias to point to something that is actually visible tweaked the default pipe alias to point to something that is actually visible
:-) :-)
2012-09-01: flattened wielded pipe segment. 2012-09-01: flattened wielded pipe segment.
2012-08-24: Added square-ish pneumatic tubes with their own autoplace code 2012-08-24: Added square-ish pneumatic tubes with their own autoplace code
(does not connect to steel pipes or pipe-oriented devices), then revised their (does not connect to steel pipes or pipe-oriented devices), then revised their
textures shortly after. Fixed a recursion bug that sometimes caused a stack textures shortly after. Fixed a recursion bug that sometimes caused a stack
overflow. Old pipes were overriding the pipeworks:pipe defintion that belongs overflow. Old pipes were overriding the pipeworks:pipe defintion that belongs
with the new pipes. with the new pipes.
2012-08-22: Added outlet grate, made it participate in autoplace algorithm. 2012-08-22: Added outlet grate, made it participate in autoplace algorithm.
Extended storage tank to show fill level in 10% steps (0% to 100%). Added Extended storage tank to show fill level in 10% steps (0% to 100%). Added
"expansion tank" that appears if the user stacks tanks upwards. (Downwards is "expansion tank" that appears if the user stacks tanks upwards. (Downwards is
not checked). not checked).
2012-08-21: Made storage tank participate in autoplace algorithm. Tuned API a 2012-08-21: Made storage tank participate in autoplace algorithm. Tuned API a
little to allow for more flexible placement. Re-organized code a bit to allow little to allow for more flexible placement. Re-organized code a bit to allow
for some upcoming rules changes. Made storage tanks' upper/lower fittins and for some upcoming rules changes. Made storage tanks' upper/lower fittins and
intake grate participate in autoplace algorithm. intake grate participate in autoplace algorithm.
2012-08-20: Added temporary nodes for storage tank and intake grating, but 2012-08-20: Added temporary nodes for storage tank and intake grating, but
without autoplace. without autoplace.
2012-08-19: Pumps and valves now fully participate in the 2012-08-19: Pumps and valves now fully participate in the
auto-rotate/auto-place algorithm. auto-rotate/auto-place algorithm.
2012-08-18: Total rewrite again. All pipes are now nice and round-looking, and 2012-08-18: Total rewrite again. All pipes are now nice and round-looking, and
they auto-connect! Also added temporary nodes for pump and valve (each with an they auto-connect! Also added temporary nodes for pump and valve (each with an
on/off setting - punch to change). No crafting recipes yet and the pipes still on/off setting - punch to change). No crafting recipes yet and the pipes still
don't do anything useful yet. Soon. don't do anything useful yet. Soon.
2012-08-06: Moved this changelog off the forum post and into a separate file. 2012-08-06: Moved this changelog off the forum post and into a separate file.
2012-08-05 (multiple updates): Rewrote pipeworks to use loops and tables to 2012-08-05 (multiple updates): Rewrote pipeworks to use loops and tables to
create the nodes. Requires far less code now. Added -X, +X, -Y, +Y, -Z, +Z create the nodes. Requires far less code now. Added -X, +X, -Y, +Y, -Z, +Z
capped stubs and a short centered horizontal segment. Changed node definitions capped stubs and a short centered horizontal segment. Changed node definitions
so that the aforementioned "short centered" segment is given on dig/drop. so that the aforementioned "short centered" segment is given on dig/drop.
Renamed it to just "pipeworks:pipe" (and pipe_loaded). Added empty/loaded Renamed it to just "pipeworks:pipe" (and pipe_loaded). Added empty/loaded
indicator images to the capped ends, removed some redundant comments. Made the indicator images to the capped ends, removed some redundant comments. Made the
empty/loaded indication at the capped end more prominent. empty/loaded indication at the capped end more prominent.
2012-07-21: Added screenshot showing pipes as they look now that nodebox 2012-07-21: Added screenshot showing pipes as they look now that nodebox
texture rotation is fixed. texture rotation is fixed.
2012-07-18: Changed the mod name and all internals to 'pipeworks' instead of 2012-07-18: Changed the mod name and all internals to 'pipeworks' instead of
'pipes'... after a couple of mistakes :-) 'pipes'... after a couple of mistakes :-)
2012-07-12: moved project to github. 2012-07-12: moved project to github.

View File

@ -1,3 +1,96 @@
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 --
---------------------- ----------------------
@ -248,6 +341,183 @@ 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
@ -255,8 +525,6 @@ 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,
@ -277,12 +545,11 @@ 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 {x=0, y=0, z=1}), get_look_dir = delay(def.look_dir or vector.new()),
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({
@ -308,14 +575,11 @@ 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({
punch = delay(), bgcolor = false,
remove = delay(), color = { r = 0, g = 0, b = 0, a = 0 },
right_click = delay(), text = def.name,
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
@ -329,37 +593,10 @@ 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 compatibilty -- Backwards compatibility
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,6 +111,12 @@ 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,70 +1,5 @@
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",
@ -194,15 +129,6 @@ 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 = {
@ -225,7 +151,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.teleporter, materials.desert_stone }, { materials.desert_stone, materials.mese, 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" }
}, },
}) })
@ -297,6 +223,26 @@ 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

@ -4,6 +4,8 @@ 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,6 +148,7 @@ 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",
@ -203,6 +204,7 @@ 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",
@ -254,10 +256,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -307,10 +310,11 @@ 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",
}, },
walkable = true, walkable = true,
pipe_connections = { top = 1 }, pipe_connections = { top = 1 },
after_place_node = function(pos) after_place_node = function(pos)
@ -335,10 +339,11 @@ 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",
}, },
walkable = true, walkable = true,
pipe_connections = { left=1, right=1, front=1, back=1, pipe_connections = { left=1, right=1, front=1, back=1,
left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
@ -373,10 +378,11 @@ 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",
}, },
walkable = true, walkable = true,
pipe_connections = { left=1, right=1, front=1, back=1, pipe_connections = { left=1, right=1, front=1, back=1,
left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
@ -432,10 +438,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -455,10 +462,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -488,10 +496,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -530,10 +539,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -600,6 +610,7 @@ 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",
@ -631,6 +642,7 @@ 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",
@ -661,10 +673,11 @@ 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",
}, },
walkable = true, walkable = true,
pipe_connections = { bottom = 1 }, pipe_connections = { bottom = 1 },
after_place_node = function(pos) after_place_node = function(pos)
@ -699,10 +712,11 @@ 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",
}, },
walkable = true, walkable = true,
pipe_connections = { bottom = 1 }, pipe_connections = { bottom = 1 },
after_place_node = function(pos) after_place_node = function(pos)
@ -752,10 +766,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)
@ -777,10 +792,11 @@ 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",
}, },
walkable = true, walkable = true,
on_place = pipeworks.rotate_on_place, on_place = pipeworks.rotate_on_place,
after_dig_node = function(pos) after_dig_node = function(pos)

View File

@ -14,20 +14,29 @@ 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,3]".. ("size[8.5,%f]"):format(form_height) ..
"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,2.3;4.05,1", "slotseq_mode", fs_helpers.cycling_button(meta, ("button[0.2,%f;4.05,1"):format(form_height - 0.7), "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,2.3;4.05,1", "exmatch_mode", fs_helpers.cycling_button(meta, ("button[4.25,%f;4.05,1"):format(form_height - 0.7), "exmatch_mode",
{S("Exact match - off"), {S("Exact match - off"),
S("Exact match - on")}).. S("Exact match - on")})..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]" ("button_exit[6.3,%f;2,1;close;" .. S("Close") .. "]"):format(form_height - 1.7)
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
@ -62,6 +71,11 @@ 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
@ -123,6 +137,7 @@ 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)
@ -186,6 +201,12 @@ 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
@ -339,7 +360,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()) fakePlayer:get_player_name(), item_tags)
return true -- only fire one item, please return true -- only fire one item, please
end end
end end
@ -389,6 +410,7 @@ 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 = {
@ -456,6 +478,10 @@ 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)
@ -477,6 +503,10 @@ 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

151
init.lua
View File

@ -4,21 +4,20 @@
-- and devices that they can connect to. -- and devices that they can connect to.
-- --
pipeworks = {} pipeworks = {
pipeworks.ui_cat_tube_list = {} ui_cat_tube_list = {},
worldpath = minetest.get_worldpath(),
pipeworks.worldpath = minetest.get_worldpath() modpath = minetest.get_modpath("pipeworks"),
pipeworks.modpath = minetest.get_modpath("pipeworks") liquids = {
local S = minetest.get_translator("pipeworks") water = {
source = minetest.registered_nodes["mapgen_water_source"].name,
pipeworks.liquids = {} flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
pipeworks.liquids.water = { },
source = minetest.registered_nodes["mapgen_water_source"].name, river_water = {
flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing source = minetest.registered_nodes["mapgen_river_water_source"].name,
} flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
pipeworks.liquids.river_water = { }
source = minetest.registered_nodes["mapgen_river_water_source"].name, }
flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
} }
dofile(pipeworks.modpath.."/default_settings.lua") dofile(pipeworks.modpath.."/default_settings.lua")
@ -36,97 +35,6 @@ 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
@ -150,14 +58,26 @@ 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/"
@ -172,9 +92,6 @@ 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
@ -191,12 +108,6 @@ 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,11 +3,36 @@ 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) function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags)
-- 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")
@ -15,6 +40,7 @@ function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner)
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
@ -79,13 +105,14 @@ 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) local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, tags)
local next_positions = {} local next_positions = {}
local max_priority = 0 local max_priority = 0
local can_go local can_go
if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then local def = minetest.registered_nodes[cnode.name]
can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack) if def and def.tube and def.tube.can_go then
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
@ -144,7 +171,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) local function go_next(pos, velocity, stack, owner, tags)
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)
@ -172,7 +199,7 @@ local function go_next(pos, velocity, stack, owner)
-- 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) local n, found, new_velocity, multimode = go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, tags)
-- 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.
@ -276,6 +303,7 @@ 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
@ -337,8 +365,9 @@ 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
if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then local def = minetest.registered_nodes[node.name]
leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner) if def.tube and def.tube.insert_object then
leftover = def.tube.insert_object(self.start_pos, node, stack, vel, self.owner)
else else
leftover = stack leftover = stack
end end
@ -353,7 +382,14 @@ luaentity.register_entity("pipeworks:tubed_item", {
return return
end end
local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color local tags
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 = true, is_ground_content = false,
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

@ -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 depends = basic_materials, xcompat
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.4.0 min_minetest_version = 5.5.0

View File

@ -76,6 +76,7 @@ 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",
@ -113,6 +114,7 @@ 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",
@ -151,6 +153,7 @@ 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)
@ -163,6 +166,7 @@ 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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

View File

@ -11,6 +11,7 @@ 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)

69
tubes/embedded_tube.lua Normal file
View File

@ -0,0 +1,69 @@
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

@ -370,7 +370,10 @@ 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. -- as all numbers in Lua are doubles. NaN values are removed.
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
@ -945,7 +948,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) can_go = function(pos, node, velocity, stack, tags)
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
@ -960,12 +963,33 @@ 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 or type(msg) ~= "string" then if not succ then
return go_back(velocity) return go_back(velocity)
end end
local r = rules[msg] if type(msg) == "string" then
return r and {r} or go_back(velocity) local side = rules[msg]
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,39 +1,6 @@
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",
@ -64,11 +31,12 @@ 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 = {
key = "node_sound_stone_defaults", key = "node_sound_stone_defaults",
}, },
tube = { tube = {
connect_sides = {front = 1, back = 1,}, connect_sides = {front = 1, back = 1,},
priority = 50, priority = 50,

View File

@ -106,6 +106,7 @@ 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",
@ -227,6 +228,7 @@ 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

@ -50,6 +50,7 @@ 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)
@ -93,6 +94,7 @@ 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."))
@ -178,6 +180,7 @@ 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",

139
tubes/tags.lua Normal file
View File

@ -0,0 +1,139 @@
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

@ -357,6 +357,7 @@ 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,

View File

@ -32,6 +32,12 @@ 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"),
@ -42,6 +48,9 @@ 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)
@ -68,6 +77,9 @@ 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 = true, is_ground_content = false,
paramtype2 = "facedir", paramtype2 = "facedir",
tubelike = 1, tubelike = 1,
groups = groups, groups = groups,