From 225a340a820b61d73717e3af34d83a61bb8b09ec Mon Sep 17 00:00:00 2001 From: Arief Bayu Purwanto Date: Wed, 18 Feb 2015 12:01:00 +0700 Subject: [PATCH] introduce table.map_length to count array size I can't seems to work with table.getn() :(. This is used primarily in plugins/bugzilla.lua --- bot/utils.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bot/utils.lua b/bot/utils.lua index 3ad714e..c5e9863 100644 --- a/bot/utils.lua +++ b/bot/utils.lua @@ -313,4 +313,15 @@ function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) -end \ No newline at end of file +end + +-- http://stackoverflow.com/a/14377694/156869 +-- get length of an array +function table.map_length(t) + local c = 0 + for k,v in pairs(t) do + c = c+1 + end + return c +end +