From ea0b889995f5673404d296103a0c3d154f405b0e Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Mon, 2 Apr 2018 23:05:36 +0800 Subject: [PATCH] commit new z.lua --- z.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/z.lua b/z.lua index f72d780..80168d7 100644 --- a/z.lua +++ b/z.lua @@ -429,13 +429,18 @@ end -- initialize random seed ----------------------------------------------------------------------- function math.random_init() - -- init random seed + -- random seed from os.time() local seed = tostring(os.time()):reverse() for _, key in ipairs(os.argv) do seed = seed .. '/' .. key end local ppid = os.getenv('PPID') seed = (ppid ~= nil) and (seed .. '/' .. ppid) or seed + -- random seed from socket.gettime() + local status, socket = pcall(require, 'socket') + if status then + seed = seed .. tostring(socket.gettime()) + end local number = 0 for i = 1, seed:len() do local k = string.byte(seed:sub(i, i))