diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-12-18 22:38:24 +0000 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-12-18 22:38:24 +0000 |
commit | 28a3ba44d165cce068491b90233a58f3cea4d1c2 (patch) | |
tree | e63631f8f9dfdadc66f9c4b77126b7ad084db778 | |
parent | d659cb38b32640656071c4cd2eddcbd97af36bf3 (diff) |
item_transport.lua: initial support in item luaentity for multiple outputs and trajectories from go_next()
-rw-r--r-- | item_transport.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/item_transport.lua b/item_transport.lua index 8a92bdb..64e4624 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -197,6 +197,12 @@ minetest.register_entity("pipeworks:color_entity", { on_activate = luaentity.on_activate, }) +-- see below for usage: +-- determine if go_next returned a multi-mode set. +local is_multimode = function(v) + return (type(v) == "table") and (v.__multimode) +end + luaentity.register_entity("pipeworks:tubed_item", { itemstring = '', item_entity = nil, @@ -297,6 +303,15 @@ luaentity.register_entity("pipeworks:tubed_item", { self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1))) self:setvelocity(velocity) end + elseif is_multimode(multimode) then + -- create new stacks according to returned data. + local s = self.start_pos + for _, split in ipairs(multimode) do + pipeworks.tube_inject_item(s, s, split.velocity, split.itemstack, self.owner) + end + -- remove ourself now the splits are sent + self:remove() + return end if new_velocity and not vector.equals(velocity, new_velocity) then |