mIRC Home    About    Download    Register    News    Help

Print Thread
#248153 24/09/14 12:49 AM
Joined: Sep 2014
Posts: 24
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 24
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
}


-Chan: #WolvenSpirit -Server: Irc.Sorcery.Net
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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.

Last edited by Loki12583; 24/09/14 03:04 AM.
Joined: Sep 2014
Posts: 24
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 24
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
}


-Chan: #WolvenSpirit -Server: Irc.Sorcery.Net

Link Copied to Clipboard