From 96dd163f473fb6ceca819e67d55bf114e3b2cc61 Mon Sep 17 00:00:00 2001 From: NullBite Date: Mon, 17 Oct 2022 00:04:21 -0400 Subject: [PATCH] Add rate limiter to syncState --- script.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/script.lua b/script.lua index 1f4f6b7..eac1566 100644 --- a/script.lua +++ b/script.lua @@ -286,9 +286,23 @@ end -- }}} -- syncState {{{ -function syncState() - ping.setSnoring(skin_state.snore_enabled) - ping.syncState(setLocalState()) +do + local counter=0 + function syncState() + -- ping.setSnoring(skin_state.snore_enabled) + if counter < 5 then + ping.syncState((setLocalState())) + counter=counter+1 + end + end + + local function cooldownDecay() + if counter>0 and world.getTime() % 4 == 0 then + counter = counter - 1 + end + end + + events.TICK:register(cooldownDecay,"syncStateCooldown") end do