summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-12-19 18:38:02 +0000
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-12-19 18:38:02 +0000
commit97522b6a244a34be9e384c151618ab8db74aea46 (patch)
treee6fe300a9647e9f096303a08c23224d22af98f20
parent755dd262086da5469489d74c919e6870870eca57 (diff)
downloadpipeworks-97522b6a244a34be9e384c151618ab8db74aea46.tar
pipeworks-97522b6a244a34be9e384c151618ab8db74aea46.tar.gz
pipeworks-97522b6a244a34be9e384c151618ab8db74aea46.tar.bz2
pipeworks-97522b6a244a34be9e384c151618ab8db74aea46.tar.xz
pipeworks-97522b6a244a34be9e384c151618ab8db74aea46.zip
item_transport.lua: update return statements in go_next() to include multimode parameter
-rw-r--r--item_transport.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/item_transport.lua b/item_transport.lua
index 154b6db..d0b0e63 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -70,6 +70,15 @@ end
+-- function called by the on_step callback of the pipeworks tube luaentity.
+-- the routine is passed the current node position, velocity, itemstack,
+-- and owner name.
+-- returns three values:
+-- * a boolean "found destination" status;
+-- * a new velocity vector that the tubed item should use, or nil if not found;
+-- * 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,
+-- then deletes itself (i.e. the original item stack).
local function go_next(pos, velocity, stack, owner)
local next_positions = {}
local max_priority = 0
@@ -120,7 +129,7 @@ local function go_next(pos, velocity, stack, owner)
end
if not next_positions[1] then
- return false, nil
+ return false, nil, nil
end
local n = (cmeta:get_int("tubedir") % (#next_positions)) + 1
@@ -128,9 +137,11 @@ local function go_next(pos, velocity, stack, owner)
cmeta:set_int("tubedir", n)
end
local new_velocity = vector.multiply(next_positions[n].vect, vel.speed)
- return true, new_velocity
+ return true, new_velocity, nil
end
+
+
minetest.register_entity("pipeworks:tubed_item", {
initial_properties = {
hp_max = 1,