changed timing code a bit

This commit is contained in:
Redo 2020-04-01 18:04:46 -05:00
parent 6fce5f4271
commit ce22e04ec7

View File

@ -12,10 +12,13 @@ dofile("port.lua")
dofile("save.lua")
OPT_TICK_ENABLED = true
OPT_TICK_TIME = 0
OPT_TICK_TIME = 0.001
OPT_FX_UPDATES = true
OPT_FX_TIME = 0.03
local tickdelay = 0
local ticksperinterval = 0
bool_to_int = {[false] = 0, [true] = 1}
local lastticktime = 0
@ -290,19 +293,20 @@ while 1 do
if OPT_TICK_ENABLED then
if time-lastticktime >= OPT_TICK_TIME then
sim:tick()
ticks = ticks + 1
lastticktime = time
local timetonext = time+OPT_TICK_TIME-os.clock()
sim:tick()
ticks = ticks+1
local sleeptime = timetonext*0.9
local sleeptime = time-os.clock()+OPT_TICK_TIME-0.03
if sleeptime>0 then socket.sleep(sleeptime) end
end
else
socket.sleep(0.1)
socket.sleep(0.05)
end
lastticktime = time
if time-lastfxtime >= OPT_FX_TIME then
sim:sendfxupdate()
sim:sendcallbacks()
@ -310,7 +314,7 @@ while 1 do
end
if time-lastmeasuretime >= 0.1 then
if #avgticks >= 20 then
if #avgticks >= 10 then
totalticks = totalticks - table.remove(avgticks, 1)
end