From 97522b6a244a34be9e384c151618ab8db74aea46 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Tue, 19 Dec 2017 18:38:02 +0000 Subject: item_transport.lua: update return statements in go_next() to include multimode parameter --- item_transport.lua | 15 +++++++++++++-- 1 file 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, -- cgit v1.2.3