View previous topic :: View next topic |
Author |
Message |
notstrider Voice
Joined: 30 Sep 2005 Posts: 3
|
Posted: Fri Sep 30, 2005 4:09 am Post subject: possible help for a one line script? |
|
|
Alright. Bear with me, I absolutely know nothing about Tcl scripting. I can't really make heads or tails of it. It's sad, I know. What I basically want to do is 'convert' a single line code from a mIRC script to Tcl.
The code is:
Code: | on 1:TEXT:cttl*:#chan:msg # $nick has $duration($calc((100 - $$2) / $$3),2) til next level -- STN! |
Now, I've tried reading up on 'bind/pub', and I basically just get lost. Also the calc code is somewhat confusing me. Any help would be greatly appreciated. I'll try to read more about Tcl too. Thanks for helping out a 'newbie'.
Oh, also. The script does this -- If the user in #chan types 'cttl 19.82 .0005' (just an example), the bot will respond with 'user has 1hr 23minutes til next level -- STN!'. It's basically cheesy, but it's for myself and friends of mine that place a certain game, so this just determines when the next time we level up. Again, it's cheesy. heh. |
|
Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Fri Sep 30, 2005 5:35 am Post subject: |
|
|
Code: | bind pub - cttl cttl:calc
proc cttl:calc {nick uhost hand chan arg} {
set arg [split $arg]
set x [lindex $arg 0]
set y [lindex $arg 1]
if {[string is double -s $x] && [string is double -s $y]} {
puthelp "PRIVMSG $chan :$nick has [duration [expr (100 - $x) / $y]] til next level -- STN!"
return 1
} else {
puthelp "NOTICE $nick :you are too stupid to enter 2 floating point values!"
return 0
}
} |
dont know if the calc is correct, since I dont know what to do with ",2"
PS: changed the script a little bit. I hope you have either the string map or the string is double inside, I almost forgot to ensure valid and safe evaluation. But with is double we also prevent causing any TCL errors... tcl errors always override errorInfo and therefore anyoing . _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Last edited by De Kus on Fri Sep 30, 2005 5:54 am; edited 4 times in total |
|
Back to top |
|
 |
notstrider Voice
Joined: 30 Sep 2005 Posts: 3
|
Posted: Fri Sep 30, 2005 5:45 am Post subject: |
|
|
it seems to be working well. thanks man. i appreciate it. if there is any issue with it, i'll be back. thanks again. |
|
Back to top |
|
 |
notstrider Voice
Joined: 30 Sep 2005 Posts: 3
|
Posted: Fri Sep 30, 2005 4:59 pm Post subject: |
|
|
haha. thanks again man. i really appreciate it.  |
|
Back to top |
|
 |
|