forked from mtcontrib/pipeworks
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>
This commit is contained in:
@ -945,7 +945,7 @@ for white = 0, 1 do
|
||||
tube = {
|
||||
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
|
||||
priority = 50,
|
||||
can_go = function(pos, node, velocity, stack)
|
||||
can_go = function(pos, node, velocity, stack, tags)
|
||||
local src = {name = nil}
|
||||
-- add color of the incoming tube explicitly; referring to rules, in case they change later
|
||||
for _, rule in pairs(rules) do
|
||||
@ -960,12 +960,33 @@ for white = 0, 1 do
|
||||
itemstring = stack:to_string(),
|
||||
item = stack:to_table(),
|
||||
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)
|
||||
end
|
||||
local r = rules[msg]
|
||||
return r and {r} or go_back(velocity)
|
||||
if type(msg) == "string" then
|
||||
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" then
|
||||
new_tags = msg.tags
|
||||
elseif type(msg.tag) == "string" then
|
||||
new_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,
|
||||
},
|
||||
after_place_node = pipeworks.after_place,
|
||||
|
Reference in New Issue
Block a user