egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Random Number Text

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
kris
Voice


Joined: 12 Sep 2006
Posts: 14
Location: Perth, Australia

PostPosted: Sun Nov 12, 2006 11:58 pm    Post subject: Random Number Text Reply with quote

it sets it, and does most of it but it doesnt reply to the number, any ideas?

Thanks for your help guys Smile

Code:

bind pub "-|-" `numbers msg_number
proc msg_number { nick host hand chan text } {
putquick "PRIVMSG $chan :\00307\002\037(\037\002\00304$nick has started The Number Guessing Game.\00307\037\002)"
putquick "PRIVMSG $chan :\00307\002\037(\037\002\00304The Number Range is From:\002 1 \002To:\002 50 \002\00307\037\002)"
putquick "PRIVMSG $chan :\00307\002\037(\037\002\00304To Guess What Number Type: `guess (Number)\002\00307\037\002)"
}
set number {
"\"1\""
"\"2\""
"\"3\""
"\"4\""
"\"5\""
"\"6\""
"\"7\""
"\"8\""
"\"9\""
"\"10\""
"\"11\""
"\"12\""
"\"13\""
"\"14\""
"\"15\""
"\"16\""
"\"17\""
"\"18\""
"\"19\""
"\"20\""
"\"21\""
"\"22\""
"\"23\""
"\"24\""
"\"25\""
"\"26\""
"\"27\""
"\"28\""
"\"29\""
"\"30\""
"\"31\""
"\"32\""
"\"33\""
"\"34\""
"\"35\""
"\"36\""
"\"37\""
"\"38\""
"\"39\""
"\"40\""
"\"41\""
"\"42\""
"\"43\""
"\"44\""
"\"45\""
"\"46\""
"\"47\""
"\"48\""
"\"49\""
"\"50\""
}
bind pub "-|-" `guess msg_guess
proc msg_guess { nick chan host handle text number } {
if {$number = $text} { putquick "PRIVMSG $chan :Congragulations, $nick, You Have Won!" }
if {$number != $text} {
if {$number > $text} { putquick "PRIVMSG $chan :This Is Bigger than the correct Number" }
if {$number < $text} { putquick "PRIVMSG $chan :This is Smaller than the correct Number" }
} else {
return
}
}

_________________
KrisDC Eggdrop Services - 2006
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Nov 13, 2006 2:46 am    Post subject: Reply with quote

You could use rand to create the random number, I don't see anything in your script that actually selects any of the numbers from the $number list.

set number [rand 50]

(Hmm does rand ever select 0 as a number? Never checked on that..)

Then do the tests like:

if {$text == $number} {#exact match}
elseif {$text < $number} {# higher than}
elseif {$text > $number} {# greater than}
else {# not even in the ballpark}

I'd also do a
if {(![string is integer -strict $text]) || ($text < 0) || ($text > 50)} {
# tell the user the guess has to be a NUMBER between 1 and 50
}

Also, you do not provide any default/fallback error message, so of course it's just doing "return" and not saying anything cos it never matches because "1" is not the same as 1
{$text == "\"1\""}
would match IF the user typed
guess "1"

I'd put a default message in there after the else, at least something like
puthelp "PRIVMSG $nick :Nope, no number matched.."
return
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber