Add sync state function, fix tick optimization
This commit is contained in:
parent
042405cb63
commit
81d66720fe
11
script.lua
11
script.lua
@ -149,6 +149,10 @@ function ping.setArmor(state)
|
|||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
function syncState()
|
||||||
|
ping.setArmor(armor_enabled)
|
||||||
|
end
|
||||||
|
|
||||||
--- Toggle Vanilla ---
|
--- Toggle Vanilla ---
|
||||||
function ping.setVanilla(state)
|
function ping.setVanilla(state)
|
||||||
if state == nil then
|
if state == nil then
|
||||||
@ -199,11 +203,16 @@ end
|
|||||||
-- Tick function --
|
-- Tick function --
|
||||||
function tick()
|
function tick()
|
||||||
-- optimization, only execute these once a second --
|
-- optimization, only execute these once a second --
|
||||||
if world.getTimeOfDay() % 20 then
|
if world.getTimeOfDay() % 20 == 0 then
|
||||||
-- if face is cracked
|
-- if face is cracked
|
||||||
if expr_current.damage==1 and player.getHealth() > 5 then
|
if expr_current.damage==1 and player.getHealth() > 5 then
|
||||||
ping.healed()
|
ping.healed()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Sync state every 10 seconds
|
||||||
|
if world.getTimeOfDay() % (20*10) == 0 then
|
||||||
|
syncState()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Damage ping (onDamage doesn't work in multiplayer) --
|
-- Damage ping (onDamage doesn't work in multiplayer) --
|
||||||
|
Loading…
x
Reference in New Issue
Block a user