<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/21621" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2024-10-20T18:47:27-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/21621</id>

		<entry>
		<author><name><![CDATA[pektek]]></name></author>
		<updated>2024-10-20T18:47:27-04:00</updated>

		<published>2024-10-20T18:47:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113086#p113086</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113086#p113086"/>
		<title type="html"><![CDATA[Re: can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113086#p113086"><![CDATA[
thank you <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_cool.gif" width="15" height="15" alt="8)" title="Cool"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=13010">pektek</a> — Sun Oct 20, 2024 6:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2024-09-24T02:45:36-04:00</updated>

		<published>2024-09-24T02:45:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113044#p113044</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113044#p113044"/>
		<title type="html"><![CDATA[Re: can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113044#p113044"><![CDATA[
If, for whatever reason, you want to generate a list containing elements from 1 to 50 don't use the stuff you've used in set number { ... }, use something like:<div class="codebox"><p>Code: </p><pre><code>proc BuildRange {start end} {    set result {}    for {set i $start} {$i &lt;= $end} {incr i} {        lappend result $i    }    return $result}</code></pre></div>instead to generate the list of numbers for you. Basic usage would be:<div class="codebox"><p>Code: </p><pre><code>set numbers [BuildRange 1 50]</code></pre></div>for example with this result:<div class="codebox"><p>Code: </p><pre><code>% set range [BuildRange 1 50]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</code></pre></div>Anyway, you don't <span style="text-decoration:underline">need</span> to generate a list of numbers just to pick a random one from the list in the end, so instead go with something like:<div class="codebox"><p>Code: </p><pre><code>proc RandomNumber {min max} {    return [expr {int(rand() * ($max - $min + 1)) + $min}]}</code></pre></div>that would pick a random number in the range of min and max, for example:<div class="codebox"><p>Code: </p><pre><code>% RandomNumber 1 5026</code></pre></div>The main issue in your code was that the random picked number wasn't stored anywhere, thus when the function terminated the number was erased from memory as well. Anyway, without further due test this out:<div class="codebox"><p>Code: </p><pre><code>namespace eval GuessNumber {    bind pub - !randomnumber [namespace current]::StartGame    bind pub - !guess [namespace current]::Guess    proc StartGame {nick host hand chan text} {        variable number        set number [RandomNumber 1 50]        puthelp "PRIVMSG $chan :\00307\002\037(\037\002\00304$nick has started The Number Guessing Game.\00307\037\002)"        puthelp "PRIVMSG $chan :\00307\002\037(\037\002\00304The Number Range is From:\002 1 \002To:\002 50 \002\00307\037\002)"        puthelp "PRIVMSG $chan :\00307\002\037(\037\002\00304To Guess What Number Type: !guess &lt;number&gt;\002\00307\037\002)"    }    proc Guess {nick uhost hand chan text} {        namespace upvar [namespace current] number no        if {[scan $text {%d} value] != 1} {            puthelp "PRIVMSG $chan :Sorry, that's not a valid number."            return        }        CheckNumber $chan $nick $value    }    proc RandomNumber {min max} {        return [expr {int(rand() * ($max - $min + 1)) + $min}]    }    proc CheckNumber {chan nick value} {        variable number        if {![info exists number] } {            puthelp "PRIVMSG $chan :Sorry, there's nothing to guess cos game hasn't been started yet."            return        }        if {$value == $number} {            puthelp "PRIVMSG $chan :Congragulations, $nick, You Have Won!"            unset number        } elseif {$value &gt; $number} {            puthelp "PRIVMSG $chan :This Is Bigger than the correct Number"        } else {            puthelp "PRIVMSG $chan :This is Smaller than the correct Number"        }    }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Sep 24, 2024 2:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2024-09-23T07:58:35-04:00</updated>

		<published>2024-09-23T07:58:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113041#p113041</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113041#p113041"/>
		<title type="html"><![CDATA[Re: can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113041#p113041"><![CDATA[
Lol, I didn't see there was a second bind/proc.<br>And willyw is right:<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark-reasonable.min.css"> <strong>script</strong>  <strong>script</strong> <div class="codebox"><pre><code class="language-tcl">proc msg_guess { nick chan host handle text } {   set unumber [join [lindex [split $text] 0]]...</code></pre></div> <strong>script</strong> But your script can't work as number is a list, not an element of the list.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Mon Sep 23, 2024 7:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2024-09-23T07:33:32-04:00</updated>

		<published>2024-09-23T07:33:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113039#p113039</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113039#p113039"/>
		<title type="html"><![CDATA[Re: can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113039#p113039"><![CDATA[
<blockquote class="uncited"><div>...<br>proc msg_guess { nick chan host handle text number } {<br><br>...<br>[/code]</div></blockquote>Compared to:   <a href="https://docs.eggheads.org/using/tcl-commands.html" class="postlink">https://docs.eggheads.org/using/tcl-commands.html</a><br>( text search down to find:     bind pub   )<br>where it says:<blockquote class="uncited"><div>4.   PUB<br><br>    bind pub &lt;flags&gt; &lt;command&gt; &lt;proc&gt;<br><br>    procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;channel&gt; &lt;text&gt;<br></div></blockquote><br>Aren't the parameters labeled out of order?<br><br><br>I hope this helps.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Mon Sep 23, 2024 7:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2024-09-23T01:51:58-04:00</updated>

		<published>2024-09-23T01:51:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113037#p113037</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113037#p113037"/>
		<title type="html"><![CDATA[Re: can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113037#p113037"><![CDATA[
Remove the quotes:<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark-reasonable.min.css"> <strong>script</strong>  <strong>script</strong> <div class="codebox"><pre><code class="language-tcl">bind pub -|- number msg_number</code></pre></div> <strong>script</strong> <p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Mon Sep 23, 2024 1:51 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pektek]]></name></author>
		<updated>2024-09-22T20:01:11-04:00</updated>

		<published>2024-09-22T20:01:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=113036#p113036</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=113036#p113036"/>
		<title type="html"><![CDATA[can i ask a question ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=113036#p113036"><![CDATA[
it sets it, and does most of it but it doesnt reply to the number, any ideas?<br><br>Thanks for your help guys ?<br><div class="codebox"><p>Code: </p><pre><code>bind pub "-|-" number 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_guessproc msg_guess { nick chan host handle text number } {if {$number = $text} { putquick "PRIVMSG $chan :Congragulations, $nick, You Have Won!" }if {$number != $text} {if {$number &gt; $text} { putquick "PRIVMSG $chan :This Is Bigger than the correct Number" }if {$number &lt; $text} { putquick "PRIVMSG $chan :This is Smaller than the correct Number" }} else {return}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=13010">pektek</a> — Sun Sep 22, 2024 8:01 pm</p><hr />
]]></content>
	</entry>
	</feed>
