From 81d66720fe3b3137f532d657960545d93b4568d3 Mon Sep 17 00:00:00 2001 From: NullBite Date: Sat, 19 Mar 2022 00:17:57 -0400 Subject: [PATCH] Add sync state function, fix tick optimization --- script.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/script.lua b/script.lua index 72b6c85..b7a4f9d 100644 --- a/script.lua +++ b/script.lua @@ -149,6 +149,10 @@ function ping.setArmor(state) end -- }}} +function syncState() + ping.setArmor(armor_enabled) +end + --- Toggle Vanilla --- function ping.setVanilla(state) if state == nil then @@ -199,11 +203,16 @@ end -- Tick function -- function tick() -- optimization, only execute these once a second -- - if world.getTimeOfDay() % 20 then + if world.getTimeOfDay() % 20 == 0 then -- if face is cracked if expr_current.damage==1 and player.getHealth() > 5 then ping.healed() end + + -- Sync state every 10 seconds + if world.getTimeOfDay() % (20*10) == 0 then + syncState() + end end -- Damage ping (onDamage doesn't work in multiplayer) --