Added player.updateHealth documentation

This commit is contained in:
mhsjlw 2015-08-28 11:19:53 -04:00
parent afb4ecb1a9
commit b00110d19a
2 changed files with 6 additions and 6 deletions

View file

@ -62,6 +62,7 @@
- [player.spawn()](#playerspawn)
- [player.setGameMode(gameMode)](#playersetgamemodegamemode)
- [player.handleCommand(command)](#playerhandlecommandcommand)
- [player.updateHealth(health)](#playerupdatehealthhealth)
- [Low level properties](#low-level-properties)
- [player._client](#player_client)
- [Low level methods](#low-level-methods)
@ -288,6 +289,10 @@ set player gameMode to `gameMode`
handle `command`
#### player.updateHealth(health)
update the player health.
### Low level properties
#### player._client

View file

@ -15,12 +15,7 @@ function inject(serv, player)
function attackEntity(entityId)
{
var attackedPlayer = serv.entities[entityId].player;
attackedPlayer.entity.health -= 1;
attackedPlayer._client.write('update_health', {
food: attackedPlayer.entity.food,
foodSaturation: 0.0,
health: attackedPlayer.entity.health
});
attackedPlayer.updateHealth(attackedPlayer.entity.health - 1);
if(attackedPlayer.entity.health==0)
attackedPlayer._writeOthers('entity_status',{