From 7bafa23bb581c48a2505d9328f209966ed974bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=BC=E5=A4=9C=E7=8B=8E=E6=98=B5?= <1046295287@qq.com> Date: Thu, 2 Jan 2025 19:37:02 +0800 Subject: [PATCH] - Add function getAvgPoint() - Add function getRandPointInCircle() - Add getRandomPointInPoly() --- Scripts/Utils.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Scripts/Utils.lua b/Scripts/Utils.lua index 712fd3b..e8384f6 100644 --- a/Scripts/Utils.lua +++ b/Scripts/Utils.lua @@ -47,6 +47,15 @@ do trigger.action.outText(text,displayTime,clearview) end + + function Utils.getTableSize(table) + local tableSize = 0 + for _,_ in pairs(table) do + tableSize = tableSize + 1 + end + + return tableSize + end --- Creates a deep copy of a object. -- Usually this object is a table. @@ -247,7 +256,7 @@ do radius = Utils.get2DDist(avg, zone[i]) end if Utils.get2DDist(avg, zone[i]) < minR then - minR = Utils.utils.get2DDist(avg, zone[i]) + minR = Utils.get2DDist(avg, zone[i]) end end --log:warn('minR: $1', minR)