Simple User and Bot Calculator

By Kirbeh_Pr0nz on May 11, 2009

!calc does the trick, works for users and yourself.

;*;*;*;*;*;*;*;*;*;
;*User Calculator*;
;*;*;*;*;*;*;*;*;*;
on *:TEXT:*:#:{
  if ($strip($1) == !calc) {
    if (!$2) { msg # 4,1Please specify an equation. }
    else { msg # 4,1Math Problem by $nick :9 $2- 4. The Answer Is:9 $calc($2-)  }
  } 
}
;*;*;*;*;*;*;*;*;
;Bot Calculator*;
;*;*;*;*;*;*;*;*;
alias Calc {
  if (!$1) { echo -a ====>No equation specified. }
  else echo -a ====>The answer to the equation $remove(!calc $1-,!calc) =4 $calc($strip($1-)) 
}

Comments

Sign in to comment.
Kirbeh_Pr0nz   -  May 12, 2009

Updated: Alias Calculator for bot.

 Respond  
Kirbeh_Pr0nz   -  May 12, 2009

i see what you mean WorldDMT. i'll add that.

 Respond  
WorldDMT   -  May 12, 2009

hi
sorry i don't speak verry well english

if writed !calc hi

====>The answer to the equation hi = 0 !!!

use alias better than on input event

must use $strip cose maby one user use a color text, bold or underline the command will not execute

so better to do

if ($strip($1) == !calc) <cmd>

but u have to add conditions to ensure that the $2 is calculated or not

so i thing that useless

 Respond  
Kirbeh_Pr0nz   -  May 12, 2009

uhh, yea. i'd say thats shorter

 Respond  
Noutrious   -  May 12, 2009
on *:TEXT:!calc*:*:msg $iif($chan,$v1 $nick -,$nick) $iif($2,$+($2-,$chr(61),$calc($2-)),* Insufficient parameters.)
alias calc echo -at $iif($1,$+($1-,$chr(61),$calc($1-)),* Insufficient parameters.)

This is short.
By the way, the on *:INPUT:.. i prefer alias much better.

 Respond  
Kirbeh_Pr0nz   -  May 12, 2009

i did what kirby said and i got > ON Unknown command

ON Unknown command
But the way i have it works just fine ^^
My main point of making this was to test out $remove because i never used it before.

 Respond  
Kirbeh_Pr0nz   -  May 12, 2009

like it isnt already short enough. lol, ill give it a shot

 Respond  
Aucun50   -  May 11, 2009

Nice, as kirby said $iif is a great tool and easy to use and understand it can also shorten scripts like this one.

 Respond  
Kirbeh_Pr0nz   -  May 11, 2009

thx for the like and the rating Jethro_

 Respond  
Jethro   -  May 11, 2009

mirc is not a scientific calculator. What it can do can only take you so far, though.

 Respond  
Kirbeh_Pr0nz   -  May 11, 2009

Thats why i had

on *:INPUT:*:{ 
if ($1 == !calc)

so it would only trigger !calc for the input. atleast i think thats how it works.

 Respond  
Firstmate   -  May 11, 2009

I'd also like to note that you have incorrectly used on INPUT.

on INPUT is trigger by several things.
-Sending a message to a channel
-(depending on event syntax) message in query
-Command
-Control-Enter'ing something

To avoid the last two, you need to check for them.
e.g.

on *:INPUT:#: {
 if ($left($1,1) != / && !$ctrlenter) {
  commands_here
 }
}
 Respond  
Kirbeh_Pr0nz   -  May 11, 2009

Now i know ^^ thx

 Respond  
Kirby   -  May 11, 2009

Cool. One thing that I'm a bit concerned with is the on input event.
If you're going to echo the result anyways, wouldn't it be easier to make an alias for it, like /calc, instead of !calc in anywhere? It's just a suggestion.

Also, (though not very important in this script), you can combine these two parts:

    if (!$2) { msg # 4,1Please specify an equation. }
    else { msg # 4,1Math Problem by $nick :9 $2- 4. The Answer Is:9 $calc($2-)  }

by using an $iif.
This can be rewritten as:

msg # $+(4,1,$iif(!$2,Please specify an equation.,Math Problem by $nick :9 $2- 4. The Answer Is:9 $calc($2-) ))

Like I said, it's not necessary in this case, but it could save a lot of space in future scripts. Same thing goes for the on input event.

 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.