Lua(Lapis)随机值返回相同的结果,即使使用randomseed

Lua(Lapis)随机值返回相同的结果,即使使用randomseed,lua,Lua,首先,我使用这个: math.randomseed(os.time()) app:match("/ttt", function() return makeString(30) end) 此函数用于检查: function makeString(l) if l < 1 then return nil end local s = "" for i = 0, l do n = math.random(0, 61)-

首先,我使用这个:

math.randomseed(os.time())
app:match("/ttt", function()
  return makeString(30)
end)
此函数用于检查:

function makeString(l)
        if l < 1 then return nil end
        local s = "" 
        for i = 0, l do
            n = math.random(0, 61)--61
            n0 = 0
            if n < 10 then n0 = n + 48
            elseif n < 36 then n0 = n - 10 + 65
            else n0 = n - 36 + 97 end
                s = s .. string.char(n0) 
        end
        return s
end
我接受不同的价值观

如果我使用这个:

math.randomseed(os.time())
app:match("/ttt", function()
  return makeString(30)
end)
和JavaScript jQuery, :

$(“#按钮5”)。单击(函数(){
var ss=“”
对于(变量i=0;i<10;i++)
{
$(“#div1”).load(“/ttt”,function(){
ss=ss+$(this).text()
警觉(ss);
});
}
$(“#第1部分”)。正文(ss);
});
我每隔一秒钟收到相同的随机字符串。 如何修复它?我试图用不同的随机数据创建数据库,但我收到了相同的字符串!!!这只是我编写的示例,但填充数据库会得到相同的结果!@#%%

有什么办法可以解决吗?

我发现这是lua的“特性”,可以使用秒生成随机数。使用此链接阅读更多信息:

但是,可以提供帮助的解决方案是访问user/dev/uradom

以下链接描述:

在我的例子中:

local frandom = io.open("/dev/urandom", "rb")
local makeString
makeString = function(l)

        local d = frandom:read(4)
        math.randomseed(d:byte(1) + (d:byte(2) * 256) + (d:byte(3) * 65536) + (d:byte(4) * 4294967296))

        if l < 1 then return nil end
        local s = "" 
        for i = 0, l do
            local n = math.random(0, 61)
            n0 = 0
            if n < 10 then n0 = n + 48
            elseif n < 36 then n0 = n - 10 + 65
            else n0 = n - 36 + 97 end
                s = s .. string.char(n0)
        end
        return s
end
localfrandom=io.open(“/dev/uradom”,“rb”)
本地生成字符串
makeString=函数(l)
本地d=frandom:read(4)
数学随机种子(d:字节(1)+(d:字节(2)*256)+(d:字节(3)*65536)+(d:字节(4)*4294967296))
如果l<1,则返回nil end
本地s=“”
对于i=0,我会
局部n=数学随机(0,61)
n0=0
如果n<10,则n0=n+48
如果n<36,则n0=n-10+65
否则n0=n-36+97结束
s=s。。string.char(n0)
结束
返回s
结束

在实际使用前弹出一些随机数字是否有用?看,不,没用。同样的结果。据我所知,如果我试图在1秒内检索随机数据,就会出现此错误。