foxygit / fake-08-xbox360 Log in
commit f964bbad80ff397c74d83f99e8cc78b351fef802
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Wed Sep 2 08:51:56 2020 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Tue Sep 15 17:09:08 2020 -0600

    Add support for table arg in rnd
---
 source/p8GlobalLuaFunctions.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/source/p8GlobalLuaFunctions.h b/source/p8GlobalLuaFunctions.h
index 39624c4..72d0e25 100644
--- a/source/p8GlobalLuaFunctions.h
+++ b/source/p8GlobalLuaFunctions.h
@@ -94,6 +94,11 @@ trace = debug.traceback
 --Math
 ---------------------------------
 function rnd(x)
+	if type(x) == 'table' then
+		local idx = math.ceil(math.random()*#x)
+		return x[idx]
+	end
+
 	return math.random()*(x or 1)
 end