Hp Bar

By owl on Mar 06, 2010

Just a short alias that creates a hp bar (196 bytes)

Use $hp(30,99)

30 being the hp left and 99 being the total hp

Image

;Owls HpBar :]

alias hp return $regsubex($regsubex($str($chr(160),$int($calc($2 / 4 - $len($1) * 2))),/(.+)..(\1)/,\1 $+ [ $1 ] $+ \2),/(.{ $+ $int($calc($1 /4 -1)) $+ })/,$+(00,$chr(44),03\100,$chr(44),04))

Comments

Sign in to comment.
Purcell   -  Mar 17, 2010

I use this one:

alias hpbar { 
  if ($1 == 100) { return 09,09.........0110009,09....... | halt }
  tokenize 32 $iif($len($1) == 1,0 $+ $1,$1)
  var %green = $ceil($calc($1 / 100 * 20))
  var %red = $calc(20 - %green)
  var %x = 1
  var %re = 09,09
  while (%x <= 20) {
    if (%x == $calc(%green + 1)) { var %re = %re $+ 04,04 }
    if (%x == 10) { var %re = %re $+ 01 $+ $left($1,1) }
    if (%x == 11) { var %re = %re $+ 01 $+ $right($1,1) }
    if (%x == 11) { vaR %re = %re $+  $+ $iif($+(04,$chr(44),04) isin %re,04 $+ $chr(44) $+ 04,09 $+ $chr(44) $+ 09) }
    if (%x != 10) && (%x != 11) var %re = %re $+ .
    inc %x
  }
  return $regsubex(%re,(01)0(01\d04),\14.4\2) $+ 
}
 Respond  
Korvin   -  Mar 07, 2010

dynamic length of the bar, like mine

bar { var %e = $2, %r = $calc($3 / %e), %x = $round($calc($1 / %r),0) | return 9,9 $+ $str(X,%x) $+ $iif($calc(%e - %x) > 0,$+(,4,$chr(44),4,$str(X,$calc(%e - %x)))) }

ex $bar(30,100,99) does the same thing as yours, but the length of the hp bar is 100 characters.

 Respond  
owl   -  Mar 07, 2010

What do you mean dynamic length Korvin?

 Respond  
Korvin   -  Mar 07, 2010

cool, try allowing a dynamic length.

 Respond  
Jethro   -  Mar 07, 2010

Be careful, Ghost-writer might be mocking you before you can say Jack Robinson. lol

 Respond  
sunslayer   -  Mar 06, 2010

@owl as a general rule of thumb, anything Ghost-writer tells you to do, do the opposite.

 Respond  
Jethro   -  Mar 06, 2010

Owwwwwwwwwlllll, I think Ghost-writer believes size does matter.

 Respond  
sunslayer   -  Mar 06, 2010

nice regsubex for your first post, try to make scripts a little longer in the future. LOL> why longer when it does the job ? (shorter code ftw) most efficient ftw
nice job tho

 Respond  
owl   -  Mar 06, 2010

why longer when it does the job ? (shorter code ftw)

 Respond  
Ghost-writer   -  Mar 06, 2010

nice regsubex for your first post, try to make scripts a little longer in the future.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.