Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fuso=0
- function getHora()
- local resposta = http.get("http://www.timeapi.org/utc/now")
- if resposta then
- local sResposta = resposta.readAll()
- resposta.close()
- for i=1,#sResposta,1 do
- if string.sub(sResposta,i,i) == "T" then
- nxt=i + 1
- break
- end
- end
- local hora = string.sub(sResposta,nxt,nxt+1) + fuso
- local minuto = string.sub(sResposta,nxt+3,nxt+4) + 0
- local segundo = string.sub(sResposta,nxt+6,nxt+7) + 0
- if hora < 0 then
- hora = hora + 24
- end
- return hora, minuto, segundo
- else
- return false
- end
- end
- function getTPS()
- print("Conectando 1")
- while not hora1 do
- hora1, minuto1, segundo1 = getHora()
- end
- local segundos1=os.clock()
- local resultado1 = hora1 * 3600 + minuto1 * 60 + segundo1
- for i=5,0,-1 do
- print(i .. " segundo(s)...")
- sleep(1)
- end
- print("Conectando 2")
- while not hora2 do
- hora2, minuto2, segundo2 = getHora()
- end
- local segundos2=os.clock()
- local resultado2 = hora2 * 3600 + minuto2 * 60 + segundo2
- resultado1 = resultado2 - resultado1
- segundos1 = segundos2 - segundos1
- tps=segundos1 * 20 / resultado1
- print("Tempo decorrido do jogo: " .. segundos1 .. "s")
- print("Tempo decorrido real: " .. resultado1 .. "s")
- print("TPS: " .. tps)
- hora1=nil
- hora2=nil
- return segundos1 * 20 / resultado1
- end
- function config()
- if fs.exists("configs") then
- if not configs then
- f = fs.open("configs","r")
- configs=textutils.unserialize(f.readAll())
- f.close()
- else
- f = fs.open("configs","w")
- f.writeLine(textutils.serialize(configs))
- f.close()
- end
- else
- configs={}
- f = fs.open("configs","w")
- f.writeLine(configs)
- f.close()
- end
- end
- config()
- while true do
- print("Calculo n:" .. #configs + 1)
- table.insert(configs,getTPS())
- config()
- print("--------------------------")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement