 |
|
 |
|
TrAsNeT Junior 2


Data inscrierii: 12/Mai/2008 Mesaje: 44 Localitate: Sighet
|
|
 |
|
 |
|
Trimis: 14/05/2008 00:19 Titlul subiectului: calculator.tcl |
|
|
set calcversion v1.0
set calcauthor TrAsNeT
proc con:calc {equation} {
set equation $equation
if {![catch {set rep [expr $equation]} error]} {return "Rezultatul: $equation = [split $rep]"} {return "Error: see .calc help"}
}
proc doit {nick uhost hand chan num} {
set doit [lindex $num 0]
set conv [lrange $num 1 end]
regsub {:} $chan { } chanarg
set chantype [lindex $chanarg 0]
set channame [lindex $chanarg 1]
set help 0
if {($doit == "calc") && ($conv == "") || ($conv == "help")} {
set help 1
set rep {
"Calc help: Putem face operatii de matematica foarte repede:"
" Adunare: .calc 1 + 1"
" Scadere: .calc 2 - 1"
" Inmultire: .calc 2 * 2"
" Impartire: .calc 4 / 2"
"Spatiile NU conteaza, operatiile se pot face si cu Spatiu si fara Spatiu: .calc 1+1 este tot aceeasi cu .calc 1 + 1"
"Acest script a fost facut de:"
"TrAsNeT @ #TeamHelp @ UnderNet"
}
} else {
if {($conv == "") || ($conv == "help")} {
set help 1
set rep {
"Cum se foloseste: PUB, MSG or DCC: .calc,"
"Examplu: Adunare 1 + 10"
" : .calc 1 + 10"
" Rezulta: 1 + 10 = 11"
}
}
}
if {($help != 1) && ($conv != "" || $conv != "help")} {
### This is the main call where all the convert proc's are done
# uncomment the line below for debug purposes, if needed.
if {$doit == "calc"} {putcmdlog "Calc Debug: nick '$nick' uhost '$uhost' hand '$hand' chan '$chan' num '$num'"}
set rep [con:$doit $conv]
}
if {($chantype == "pub")} {
if {$help == 1} {
foreach line $rep {puthelp "PRIVMSG $nick :$line"}
return
} else {
puthelp "PRIVMSG $channame :[join $rep]"
return
}
}
if {$chantype == "privmsg"} {
if {$help == 1} {
foreach line $rep {puthelp "PRIVMSG $nick :$line"}
return
} else {
puthelp "PRIVMSG $nick :[join $rep]"
return
}
}
if {$chantype == "dcc"} {
set idx $channame
if {$help == 1} {
foreach line $rep {putdcc $idx "$line"}
return
} else {
putdcc $idx "[join $rep]"
return
}
}
}
proc con:calc:pub {nick uhost hand chan num} {doit $nick $uhost $hand pub:$chan "calc [split $num]"}
proc con:calc:msg {nick uhost hand num} {doit $nick $uhost $hand privmsg "calc [split $num]"}
proc con:calc:dcc {hand idx num} {doit "" "" $hand dcc:$idx "calc [split $num]"}
bind pub - .calc con:calc:pub
bind msg - .calc con:calc:msg
bind dcc - calc con:calc:dcc
putlog "Calculator TCL Version $calcversion Made By $calcauthor !" |
|