Skip to content
Snippets Groups Projects
Commit e1d58c0a authored by joenas's avatar joenas
Browse files

Only sync once every second. Also:

Fixed some indentations
parent 5c04e733
No related branches found
No related tags found
No related merge requests found
...@@ -92,25 +92,27 @@ end) ...@@ -92,25 +92,27 @@ 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()
if matrix.connected then if matrix.connected then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment