Only sync once every second. Also:

Fixed some indentations
This commit is contained in:
joenas 2017-06-21 21:28:50 +02:00
parent 5c04e733f5
commit e1d58c0aef

View File

@ -92,25 +92,27 @@ end)
dofile(modpath.."/callback.lua")
local stepnum = 0
minetest.register_globalstep(function(dtime) return matrix.step(dtime) end)
function matrix.step()
local stepnum = 0
local interval = 1
local counter = 0
function matrix.step(dtime)
if stepnum == 3 then
matrix.connect()
end
stepnum = stepnum + 1
if not matrix.connected then return end
-- Hooks will manage incoming messages and errors
counter = counter + dtime
if counter >= interval and matrix.connected then
counter = counter - interval
local good, err = xpcall(function() client:_sync() end, debug.traceback)
if not good then
print(err)
return
end
end
end
function matrix.connect()
if matrix.connected then