mIRC Homepage
Posted By: SophisDecay {Help} Please? - 24/09/14 12:49 AM
I have gave it my all and I'm so very close to achieving my dream bot!!! i just do not understand the $calc

Almost everything works but its only subtracting one from my $cache in stead of the number healed, Please any input would be greatly appreciated!


on *:text:!Eat*:#Lunarmyst:{
if (%health [ $+ [ $nick ] ] >= 100) {
msg $chan You Already Have Full Health!
halt
}
dec %cache ($calc($health[ $+ [ $nick ] ] ) $+ )
/msg $Chan $nick You Have Just Ate from the Cache and restored %health [ $+ [ $nick ] ] health!!
/msg $Chan Remaining cache: %cache Points
set %health [ $+ [ $nick ] ] 100
}
Posted By: Loki12583 Re: {Help} Please? - 24/09/14 02:49 AM
Code:
on *:text:!Eat*:#Lunarmyst:{
  if (%health [ $+ [ $nick ] ] >= 100) {
    msg $chan You Already Have Full Health!
    return
  }

  var %restore = $iif($calc( 100 - %health [ $+ [ $nick ] ] ) < %cache, $v1, $v2)

  if (%restore <= 0) {
    msg $chan Cache is empty
    return
  }

  dec %cache %restore
  inc %health [ $+ [ $nick ] ] %restore

  msg $chan $nick You Have Just Ate from the Cache and restored %restore health!!
  msg $chan Remaining cache: %cache Points
}


From context I assume this is what you want. I've added the appropriate logic such that %cache will not become negative.
Posted By: SophisDecay Re: {Help} Please? - 24/09/14 11:24 PM
Oh my Thank you so Much! if i wanted it to work for !Drink
Would i need to set a cache for the water as well?

on *:text:!drink*:#Lunarmyst:{
if (%thirst [ $+ [ $nick ] ] >= 100) {
msg $chan You Already Have Full Thirst!
return
}
/msg $Chan $nick You Have Just drank from the lake and restored %thirst [ $+ [ $nick ] ] Thirst Points!!
set %thirst [ $+ [ $nick ] ] 100
}
© mIRC Discussion Forums