Move health to old state, add underwater state
Sync when underwater state changes
This commit is contained in:
parent
f1ad854993
commit
89dbf2ef2c
10
script.lua
10
script.lua
@ -498,7 +498,8 @@ end
|
|||||||
|
|
||||||
-- initialize values -- {{{
|
-- initialize values -- {{{
|
||||||
function player_init()
|
function player_init()
|
||||||
old_health=player.getHealth()
|
old_state={}
|
||||||
|
old_state.health=player.getHealth()
|
||||||
syncState()
|
syncState()
|
||||||
end
|
end
|
||||||
-- Initial configuration --
|
-- Initial configuration --
|
||||||
@ -537,14 +538,17 @@ function tick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Damage ping (onDamage doesn't work in multiplayer) --
|
-- Damage ping (onDamage doesn't work in multiplayer) --
|
||||||
if old_health>player.getHealth() then
|
if old_state.health>player.getHealth() then
|
||||||
-- debug
|
-- debug
|
||||||
-- print(string.format('old_health=%03.2f, player.getHealth=%03.2f', old_health,player.getHealth()))
|
-- print(string.format('old_health=%03.2f, player.getHealth=%03.2f', old_health,player.getHealth()))
|
||||||
ping.oof(player.getHealth())
|
ping.oof(player.getHealth())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if old_state.isUnderwater ~= player.isUnderwater() then syncState() end
|
||||||
|
old_state.isUnderwater=player.isUnderwater()
|
||||||
-- End of tick --
|
-- End of tick --
|
||||||
old_health=player.getHealth()
|
old_state.health=player.getHealth()
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user