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