This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

possible help for a one line script?

Old posts that have not been replied to for several years.
Locked
n
notstrider
Voice
Posts: 3
Joined: Fri Sep 30, 2005 4:03 am

possible help for a one line script?

Post by notstrider »

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: Select all

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.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Code: Select all

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 :D.
Last edited by De Kus on Fri Sep 30, 2005 5:54 am, edited 4 times in total.
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...
n
notstrider
Voice
Posts: 3
Joined: Fri Sep 30, 2005 4:03 am

Post by notstrider »

it seems to be working well. thanks man. i appreciate it. if there is any issue with it, i'll be back. thanks again.
n
notstrider
Voice
Posts: 3
Joined: Fri Sep 30, 2005 4:03 am

Post by notstrider »

haha. thanks again man. i really appreciate it. :)
Locked