im a starter with tcl and was working on a little dice game, but i just keep getting errors on this code... have been searching around for a couple of hours now and tried lots of things but i cant get it to work.... whenever i call the proc throw evrything goes well untill it calls the proc calctotals. then it gives me this errormessage over the partyline :
[maxxje] [16:17] Tcl error [throw]: syntax error in expression "(3"
proc throw {nick host chan args} {
global dice1
global dice2
global total
set dice1 [expr [rand 6] + 1]
set dice2 [expr [rand 6] + 1]
putserv "notice $nick : Dice 1 : $dice1"
putserv "notice $nick : Dice 2 : $dice2"
[calctotals]
putserv "notice $nick : Total score for this throw : $total"
putserv "notice $nick : Required score : ***"
}
proc calctotals {args} {
global dice1
global dice2
global total
if ($dice1 == $dice2){
set total $dice1
append total 00
}
if ($dice1 > $dice2){
set total $dice1
append total $dice2
}
if ($dice2 > $dice1){
set total $dice2
append total $dice1
}
}
1. [calctotals] should just be calctotals. Use [ ] around it when you want to use the return value, like set blah [calctotals].
2. The if statement's condition should be in { }, not ( ).
And a suggestion: if I remember correctly, eggdrop's rand function really sucks. It's better to use tcl's, like this: set dice1 [expr int(rand() * 6) + 1]
Even better, I found, is to use eggdrop's md5 function to create your own random number generator. It creates a smooth distribution and avoids long runs of the same number.