From 53d90b4b86f15c386ad9ee510a8a094050a48b53 Mon Sep 17 00:00:00 2001 From: tacigar Date: Mon, 19 Dec 2016 12:00:22 +0900 Subject: [PATCH] Add maidroid_core's aux --- maidroid_core/cores/_aux.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 maidroid_core/cores/_aux.lua diff --git a/maidroid_core/cores/_aux.lua b/maidroid_core/cores/_aux.lua new file mode 100644 index 0000000..a4dcd89 --- /dev/null +++ b/maidroid_core/cores/_aux.lua @@ -0,0 +1,28 @@ +------------------------------------------------------------ +-- Copyright (c) 2016 tacigar. All rights reserved. +-- https://github.com/tacigar/maidroid +------------------------------------------------------------ + +maidroid_core._aux = {} + +local default_searching_range = { + x = 5, y = 1, z = 5, +} + +-- maidroid_core._aux.search_surrounding searchs maidroid surrounding. +function maidroid_core._aux.search_surrounding(self, pred, searching_range) + if searching_range == nil then + searching_range = default_searching_range + end + for x = -searching_range.x, searching_range.x do + for y = -searching_range.y, searching_range.y do + for z = -searching_range.z, searching_range.z do + local pos = {x = x, y = y, z = z} + if pred(self, pos) then + return pos + end + end + end + end + return nil +end