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")
|
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user