summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-04 21:00:16 +0200
committerAki <nthirtyone@gmail.com>2017-09-04 21:00:16 +0200
commit994768edaf706c890bcad6d6cdecedaf0f4bdec1 (patch)
treebad68a09d5d1ee207b1833dc5debaaaa8d0caba1
parentde2ee3b44373da6e3c110d00644d04c78f2efa24 (diff)
downloadroflnauts-994768edaf706c890bcad6d6cdecedaf0f4bdec1.zip
roflnauts-994768edaf706c890bcad6d6cdecedaf0f4bdec1.tar.gz
roflnauts-994768edaf706c890bcad6d6cdecedaf0f4bdec1.tar.bz2
Added callEachBut method
-rw-r--r--not/Group.lua18
1 files changed, 18 insertions, 0 deletions
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