Only sync once every second. Also:
Fixed some indentations
This commit is contained in:
parent
5c04e733f5
commit
e1d58c0aef
16
init.lua
16
init.lua
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user