Paste #7572: healthbar

Date: 2014/07/28 16:50:54 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


PlayerHealthBar: 
  type: world 
  events: 
    on player join:
    - flag player healthbar
    - run determinehealth 
    on player quits: 
    - flag healthbar:!
    entity damaged:
    - run healplayer
determinehealth: 
    type: task 
    script:
    - if <player.has_flag[healthbar]> {
      - define currenthealth <player.health> 
      - define %totalhealth% 20 
      - if <player.equipment.helmet.lore> contains health { 
        - define %currenthealth% <%currenthealth%.add[health +]> 
        - define %totalhealth% <%totalhealth%.add[health +]>
        - adjust <player> show_boss_bar:%currenthealth%/%totalhealth% 
        - run determinehealth 
        }
      - if <player.equipment.chestplate.lore> contains health { 
        - define %currenthealth% <%currenthealth%.add[health +]> 
        - define %totalhealth% <%totalhealth%.add[health +]>
        - adjust <player> show_boss_bar:%currenthealth%/%totalhealth% 
        - run determinehealth 
        } 
      - if <player.equipment.leggings.lore> contains health { 
        - define %currenthealth% <%currenthealth%.add[health +]> 
        - define %totalhealth% <%totalhealth%.add[health +]>
        - adjust <player> show_boss_bar:%currenthealth%/%totalhealth% 
        - run determinehealth 
        }
      - if <player.equipment.shoes.lore> contains health { 
        - define %currenthealth% <%currenthealth%.add[health +]> 
        - define %totalhealth% <%totalhealth%.add[health +]>
        - adjust <player> show_boss_bar:%currenthealth%/%totalhealth% 
        - run determinehealth 
        } 
      } else {
      - announce "<player.name> has logged off"
healplayer:
    type: task
    script:
    - health <player> 20