mirror of
https://github.com/arsdragonfly/random_messages.git
synced 2025-01-09 17:30:27 +01:00
fix
This commit is contained in:
parent
597bfa0e5a
commit
002f32c6ae
8
init.lua
8
init.lua
@ -11,8 +11,14 @@ math.randomseed(os.time())
|
|||||||
random_messages = {}
|
random_messages = {}
|
||||||
random_messages.messages = {} --This table contains all messages.
|
random_messages.messages = {} --This table contains all messages.
|
||||||
|
|
||||||
|
function table.count( t )
|
||||||
|
local i = 0
|
||||||
|
for k in pairs( t ) do i = i + 1 end
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
|
||||||
function table.random( t )
|
function table.random( t )
|
||||||
local rk = math.random( 1, table.Count( t ) )
|
local rk = math.random( 1, table.count( t ) )
|
||||||
local i = 1
|
local i = 1
|
||||||
for k, v in pairs( t ) do
|
for k, v in pairs( t ) do
|
||||||
if ( i == rk ) then return v, k end
|
if ( i == rk ) then return v, k end
|
||||||
|
Loading…
Reference in New Issue
Block a user