summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@linuxworks.belug.de>2017-08-22 14:46:36 +0200
committerroot <root@linuxworks.belug.de>2017-08-22 14:46:36 +0200
commit89c704fc3d5e9115caf5b4d6564b10797bb95beb (patch)
treebe1d7071868d22a23671370f44bb056ae7b14e0b
parent5ca864d2fc983fcb2d905b8111983dc6b1771ddd (diff)
parenta5e1bfa0e824ab70877803d087c97440ff729cac (diff)
Merge branch 'master' of https://github.com/minetest-mods/pipeworks
-rw-r--r--compat-chests.lua13
-rw-r--r--filter-injector.lua15
-rw-r--r--item_transport.lua11
3 files changed, 25 insertions, 14 deletions
diff --git a/compat-chests.lua b/compat-chests.lua
index 7cff6fd..69eb2f1 100644
--- a/compat-chests.lua
+++ b/compat-chests.lua
@@ -36,7 +36,7 @@ local function get_chest_formspec(pos)
pipeworks.button_on
}
)..pipeworks.button_label
-
+
return formspec
end
@@ -62,7 +62,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local sound = open_chests[pn].sound
local swap = open_chests[pn].swap
local node = minetest.get_node(pos)
-
+
open_chests[pn] = nil
for k, v in pairs(open_chests) do
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
@@ -71,13 +71,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
minetest.after(0.2, function()
minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
-
+
-- Pipeworks notification
pipeworks.after_place(pos)
end)
minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
end
-
+
-- Pipeworks Switch
if pipeworks.may_configure(pos, player) and not fields.quit then
fs_helpers.on_receive_fields(pos, fields)
@@ -142,6 +142,7 @@ override_protected = {
end
return inv:room_for_item("main", stack)
end,
+ input_inventory = "main",
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
},
after_dig_node = pipeworks.after_dig
@@ -191,9 +192,9 @@ override = {
after_dig_node = pipeworks.after_dig
}
--[[local override_common = {
-
+
}
-for k,v in pairs(override_common) do
+for k,v in pairs(override_common) do
override_protected[k] = v
override[k] = v
end]]
diff --git a/filter-injector.lua b/filter-injector.lua
index 45b27c4..1f6a90a 100644
--- a/filter-injector.lua
+++ b/filter-injector.lua
@@ -156,7 +156,7 @@ local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,fromi
end
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir)
- local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item)
+ local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name())
return true-- only fire one item, please
end
end
@@ -317,8 +317,17 @@ local function punch_filter(data, filtpos, filtnode, msg)
exact_match = filtmeta:get_int("exmatch_mode")
end
- local frommeta = minetest.get_meta(frompos)
- local frominv = frommeta:get_inventory()
+ local frominv
+ if fromtube.return_input_invref then
+ local pos = vector.add(filtpos, vector.multiply(dir, -1))
+ frominv = fromtube.return_input_invref(pos, fromnode, dir, owner)
+ if not frominv then
+ return
+ end
+ else
+ local frommeta = minetest.get_meta(frompos)
+ frominv = frommeta:get_inventory()
+ end
if fromtube.before_filter then fromtube.before_filter(frompos) end
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
local done = false
diff --git a/item_transport.lua b/item_transport.lua
index b2d2aa2..551db07 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -7,13 +7,14 @@ function pipeworks.tube_item(pos, item)
error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
end
-function pipeworks.tube_inject_item(pos, start_pos, velocity, item)
+function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner)
-- Take item in any format
local stack = ItemStack(item)
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
obj:set_item(stack:to_string())
obj.start_pos = vector.new(start_pos)
obj:setvelocity(velocity)
+ obj.owner = owner
--obj:set_color("red") -- todo: this is test-only code
return obj
end
@@ -49,7 +50,7 @@ minetest.register_globalstep(function(dtime)
end
end)
-local function go_next(pos, velocity, stack)
+local function go_next(pos, velocity, stack, owner)
local next_positions = {}
local max_priority = 0
local cnode = minetest.get_node(pos)
@@ -84,7 +85,7 @@ local function go_next(pos, velocity, stack)
local tube_priority = (tube_def and tube_def.priority) or 100
if tubedevice > 0 and tube_priority >= max_priority then
if not tube_def or not tube_def.can_insert or
- tube_def.can_insert(npos, node, stack, vect) then
+ tube_def.can_insert(npos, node, stack, vect, owner) then
if tube_priority > max_priority then
max_priority = tube_priority
next_positions = {}
@@ -260,7 +261,7 @@ luaentity.register_entity("pipeworks:tubed_item", {
if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
local leftover
if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
- leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel)
+ leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
else
leftover = stack
end
@@ -276,7 +277,7 @@ luaentity.register_entity("pipeworks:tubed_item", {
end
if moved then
- local found_next, new_velocity = go_next(self.start_pos, velocity, stack) -- todo: color
+ local found_next, new_velocity = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
local rev_vel = vector.multiply(velocity, -1)
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)))