mIRC Homepage

calc script

Posted By: botnoob

calc script - 14/07/10 02:09 PM

Ok, so basically I have a calc script.

Here is coding:

n0=on *:text:!calculation*:#:{
n1= set %ans [ $+ [ $nick] ] $bytes($calc($remove($2-,$chr(44))),bd)
n2= msg $chan $bytes($calc($remove($2-,$chr(44))),bd)

Wondering if anybody could give me a solution so that the users name is displayed and then the answer.

For example if John were to do:
!calculation 1+1

It would come out as:
John, the answer is: 2

Posted By: Riamus2

Re: calc script - 14/07/10 02:18 PM

Change the msg line to include $nick and write it however you want it to appear... just like if you were typing it to the channel. Note that if you want a comma to be next to the nick, write it as $nick $+ , (that will combine the two so you don't have a space between them).
Posted By: Horstl

Re: calc script - 14/07/10 03:13 PM

Why the $bytes identifier? confused

Below's but a quick scribble - I'm sure you can find some elaborated calculation scripts at the various dedicated mIRCscript websites.
on *:text:!calc*:#: {

  ; no parameter given: syntax help
  if ($2 == $null) { msg $chan $nick $+ $chr(44) try: !calculation <stuff to calculate> }

  ; parameters don't contain any digit or "pi"
  elseif (!$regex($2-,/(?:\d|pi)/)) { msg $chan Nothing to calculate, $nick $+ ! }

  ; calculation output, with x replaced by *, commas by dots, pi by it's value
  ; note that it isn't supporting $sqrt, $sin, $cos, $tan etc as yet, and odd bracket usage may break the calculation, like in " 5+2*(3 "
  else { msg $chan $nick $+ $chr(44) the answer is: $calc( $replace($2-,x,*,$chr(44),$chr(46),pi,$pi) ) }
Posted By: RusselB

Re: calc script - 14/07/10 04:30 PM

Using $bytes is a quick and easy way of getting commas in the output in the correct (standard) locations.
Posted By: botnoob

Re: calc script - 14/07/10 06:00 PM

Cheers guys.
I got it to work, but as seen below I get 2 answers. lol

My finishing code was:

n0=on *:text:!cal*:#a:{
n1= msg $chan $nick $chan; the answer is $bytes($calc($remove($2-,$chr(44))),bd)

Here was the line

[18:57] <~John> !cal 1+1
[18:57] <@JW|Bot> 2
[18:57] <@JW|Bot> John the answer is 2

What part can I take out to remove the first answel and only have the second.

Hope you can help, off to the cinema now and will check when I get beck to see if anybody can help.

Thanks a lot.
Posted By: Horstl

Re: calc script - 14/07/10 07:44 PM

Ah, I tend to forget about the english way of writing numerary.
For example here in Germany, we put a comma where you put the dot, and sometimes we use dots as the column separator - e.g.: 25,95 , 5.000,00 ...renders my suggestion above into a "localized" version... laugh Either is against ISO anyway. whistle
Posted By: Horstl

Re: calc script - 14/07/10 07:48 PM

Most likely, you've loaded more than one script with a matching on text event.
Also note that there's a superfluous "$chan;" identifier in your code.
Posted By: RusselB

Re: calc script - 14/07/10 08:54 PM

While it is against ISO, it is not against tradition, which, in my experience, overrides technical procedures more often than not.

Additionally, as I understand it, the $bytes uses the general format for your local area as specified in the Windows numeric format. Thus, $bytes in your area may show the format that you are expecting.
Posted By: botnoob

Re: calc script - 14/07/10 11:18 PM

i guess i will just need to fiddle around and do a bit of trial and error.
Posted By: botnoob

Re: calc script - 15/07/10 03:04 AM

Ok I done it.

Works now, and here was my finish product:

on *:text:!cal*:#:{
/set %calc.answer $bytes($calc($remove($2-,$chr(44))),bd)
msg $chan $nick the answer is %calc.answer
/unset %calc.answer
Posted By: chacha

Re: calc script - 15/07/10 01:19 PM

why /set /unset the command /var exist
/var is local variable
/help /var
Posted By: botnoob

Re: calc script - 15/07/10 02:20 PM

It was my friend who has been scripting for a very short amount of time. 5-6 months maybe. But he rewrit it for me, and it has come out exactly how i wanted it. i could always ask him for you if you like?
Posted By: ziv

Re: calc script - 16/07/10 12:29 PM

Pfft, why even use /vars, he should just put it directly in the .msg line.

Posted By: botnoob

Re: calc script - 20/07/10 10:57 PM

Thanks for everybody that helped me out laugh
© 2022 mIRC Discussion Forums