From 89dbf2ef2cb60ac4e1c190c76dd5cc52091ae510 Mon Sep 17 00:00:00 2001 From: NullBite Date: Mon, 21 Mar 2022 23:12:22 -0400 Subject: [PATCH] Move health to old state, add underwater state Sync when underwater state changes --- script.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script.lua b/script.lua index ec5f603..3ae8756 100644 --- a/script.lua +++ b/script.lua @@ -498,7 +498,8 @@ end -- initialize values -- {{{ function player_init() - old_health=player.getHealth() + old_state={} + old_state.health=player.getHealth() syncState() end -- Initial configuration -- @@ -537,14 +538,17 @@ function tick() end -- Damage ping (onDamage doesn't work in multiplayer) -- - if old_health>player.getHealth() then + if old_state.health>player.getHealth() then -- debug -- print(string.format('old_health=%03.2f, player.getHealth=%03.2f', old_health,player.getHealth())) ping.oof(player.getHealth()) end + + if old_state.isUnderwater ~= player.isUnderwater() then syncState() end + old_state.isUnderwater=player.isUnderwater() -- End of tick -- - old_health=player.getHealth() + old_state.health=player.getHealth() end -- }}}