From 994768edaf706c890bcad6d6cdecedaf0f4bdec1 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 4 Sep 2017 21:00:16 +0200 Subject: Added callEachBut method --- not/Group.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'not/Group.lua') diff --git a/not/Group.lua b/not/Group.lua index 5dedc9a..d9c0b9c 100644 --- a/not/Group.lua +++ b/not/Group.lua @@ -20,10 +20,28 @@ function Group:callEach (func, ...) return results end +--- Calls function with parameters for each but one child. +-- @param avoid child to avoid calling +-- @param func key of function to call +-- @param ... parameters passed to function +-- @return table with calls' results +function Group:callEachBut (avoid, func, ...) + local results = {} + for _,child in ipairs(self.children) do + if child ~= avoid then + if type(child[func]) == "function" then + table.insert(results, child[func](child, ...)) + end + end + end + return results +end + --- Calls function with parameters for one child based on controller set. -- @param set controller set -- @param func key of function to call -- @param ... parameters passed to function +-- @return results of called function function Group:callWithSet (set, func, ...) for i,test in ipairs(Controller.getSets()) do if test == set then -- cgit v1.1