mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-06 19:50:40 +00:00
Added player.updateHealth documentation
This commit is contained in:
parent
afb4ecb1a9
commit
b00110d19a
2 changed files with 6 additions and 6 deletions
|
|
@ -62,6 +62,7 @@
|
||||||
- [player.spawn()](#playerspawn)
|
- [player.spawn()](#playerspawn)
|
||||||
- [player.setGameMode(gameMode)](#playersetgamemodegamemode)
|
- [player.setGameMode(gameMode)](#playersetgamemodegamemode)
|
||||||
- [player.handleCommand(command)](#playerhandlecommandcommand)
|
- [player.handleCommand(command)](#playerhandlecommandcommand)
|
||||||
|
- [player.updateHealth(health)](#playerupdatehealthhealth)
|
||||||
- [Low level properties](#low-level-properties)
|
- [Low level properties](#low-level-properties)
|
||||||
- [player._client](#player_client)
|
- [player._client](#player_client)
|
||||||
- [Low level methods](#low-level-methods)
|
- [Low level methods](#low-level-methods)
|
||||||
|
|
@ -288,6 +289,10 @@ set player gameMode to `gameMode`
|
||||||
|
|
||||||
handle `command`
|
handle `command`
|
||||||
|
|
||||||
|
#### player.updateHealth(health)
|
||||||
|
|
||||||
|
update the player health.
|
||||||
|
|
||||||
### Low level properties
|
### Low level properties
|
||||||
|
|
||||||
#### player._client
|
#### player._client
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,7 @@ function inject(serv, player)
|
||||||
function attackEntity(entityId)
|
function attackEntity(entityId)
|
||||||
{
|
{
|
||||||
var attackedPlayer = serv.entities[entityId].player;
|
var attackedPlayer = serv.entities[entityId].player;
|
||||||
attackedPlayer.entity.health -= 1;
|
attackedPlayer.updateHealth(attackedPlayer.entity.health - 1);
|
||||||
attackedPlayer._client.write('update_health', {
|
|
||||||
food: attackedPlayer.entity.food,
|
|
||||||
foodSaturation: 0.0,
|
|
||||||
health: attackedPlayer.entity.health
|
|
||||||
});
|
|
||||||
|
|
||||||
if(attackedPlayer.entity.health==0)
|
if(attackedPlayer.entity.health==0)
|
||||||
attackedPlayer._writeOthers('entity_status',{
|
attackedPlayer._writeOthers('entity_status',{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue