|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
Ok, so basically I have a calc script.
Here is coding:
[script] 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) n3=}
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
Thanks
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
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).
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Why the $bytes identifier? 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) ) }
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Using $bytes is a quick and easy way of getting commas in the output in the correct (standard) locations.
|
|
|
|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
Cheers guys. I got it to work, but as seen below I get 2 answers. lol
My finishing code was:
[script] n0=on *:text:!cal*:#a:{ n1= msg $chan $nick $chan; the answer is $bytes($calc($remove($2-,$chr(44))),bd) n2=}
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.
Last edited by botnoob; 14/07/10 06:00 PM.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
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... Either is against ISO anyway.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
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.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
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.
|
|
|
|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
i guess i will just need to fiddle around and do a bit of trial and error.
|
|
|
|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
Ok I done it.
Works now, and here was my finish product:
[script] on *:text:!cal*:#:{ /set %calc.answer $bytes($calc($remove($2-,$chr(44))),bd) msg $chan $nick the answer is %calc.answer /unset %calc.answer }
|
|
|
|
Joined: Feb 2009
Posts: 133
Vogon poet
|
Vogon poet
Joined: Feb 2009
Posts: 133 |
why /set /unset the command /var exist /var is local variable /help /var
WorldDMT
|
|
|
|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
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?
|
|
|
|
Joined: Sep 2009
Posts: 52
Babel fish
|
Babel fish
Joined: Sep 2009
Posts: 52 |
Pfft, why even use /vars, he should just put it directly in the .msg line.
ziv.
|
|
|
|
Joined: Jul 2010
Posts: 23
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2010
Posts: 23 |
Thanks for everybody that helped me out
|
|
|
|
|