This commit is contained in:
Zheyu Shen 2015-10-02 11:42:31 +08:00
parent 597bfa0e5a
commit 002f32c6ae
1 changed files with 7 additions and 1 deletions

View File

@ -11,8 +11,14 @@ math.randomseed(os.time())
random_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 )
local rk = math.random( 1, table.Count( t ) )
local rk = math.random( 1, table.count( t ) )
local i = 1
for k, v in pairs( t ) do
if ( i == rk ) then return v, k end