Move health to old state, add underwater state

Sync when underwater state changes
This commit is contained in:
NullBite 2022-03-21 23:12:22 -04:00
parent f1ad854993
commit 89dbf2ef2c
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A

View File

@ -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
-- }}}