From a40f5f2f679ace9f601504c5788c4297edbca32e Mon Sep 17 00:00:00 2001 From: Andrew Edstrom Date: Thu, 28 Jan 2021 15:25:39 -0800 Subject: [PATCH] Call rnd(table) to get a random table element As of 2.0.0, you can call `rnd` with a table as the argument to get a random element from the table. This PR adds that to the `tables` tab. From the [PICO-8 manual](https://www.lexaloffle.com/pico-8.php?page=manual): ``` rnd x Returns a random number n, where 0 <= n < x If you want an integer, use flr(rnd(x)) If x is an array-style table, return a random element between table[1] and table[#table]. ``` --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index fbb792b..acc2e37 100755 --- a/index.html +++ b/index.html @@ -450,6 +450,7 @@
table manipulation
count(t) -- returns number of elements in the table del(t, v) -- delete first instance of v in t foreach(t, f) -- call f() for each v in t +rnd(t) -- returns a random element from t pairs(t) -- used in 'for k,v in pairs(t)' loops
metatables :: view metatables thread