<?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/19706" />

	<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>2014-05-26T01:10:53-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2014-05-26T01:10:53-04:00</updated>

		<published>2014-05-26T01:10:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102851#p102851</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102851#p102851"/>
		<title type="html"><![CDATA[Rand and if's]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102851#p102851"><![CDATA[
Since [rand 6] will return results from 0 to 5 you need to either add 1 to it like [expr [rand 6] +1] to have both included or change the if lines to start with 0.<br><br>Anyway, I would honestly go with a <em class="text-italics">switch</em> than a bunch of <em class="text-italics">if</em> statements cos the interpreter will pass through them all, while the switch will go directly to the corresponding number and exit.<div class="codebox"><p>Code: </p><pre><code>proc fight_kick {nick host hand chan text} {set rfu [expr [rand 6] +1]switch -- $rfu {1 {set msg "!fu"}2 {set msg "!fd"}3 {set msg "!fg"}4 {set msg "!fk"}5 {set msg "!fp"}6 {set msg "!fj"}}putmsg $chan $msg}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon May 26, 2014 1:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2014-05-24T16:46:30-04:00</updated>

		<published>2014-05-24T16:46:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102845#p102845</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102845#p102845"/>
		<title type="html"><![CDATA[Re: I'm new to TCL, and I need a lil help with rand and if's]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102845#p102845"><![CDATA[
Try this<br><div class="codebox"><p>Code: </p><pre><code>proc fight_kick { nick host hand chan text } {     set rfu [rand 6]     if { $rfu == 1 } { putmsg $chan "!fu" }     if { $rfu == 2 } { putmsg $chan "!fd" }     if { $rfu == 3 } { putmsg $chan "!fg" }     if { $rfu == 4 } { putmsg $chan "!fk" }     if { $rfu == 5 } { putmsg $chan "!fp" }     if { $rfu == 6 } { putmsg $chan "!fj" }} </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Sat May 24, 2014 4:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[wikked]]></name></author>
		<updated>2014-05-24T16:06:59-04:00</updated>

		<published>2014-05-24T16:06:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=102842#p102842</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=102842#p102842"/>
		<title type="html"><![CDATA[Rand and if's]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=102842#p102842"><![CDATA[
I'm new to TCL, and I need a lil help with rand and if's.<div class="codebox"><p>Code: </p><pre><code>proc fight_kick { nick host hand chan text } {     set $rfu rand(1,6)     if { $rfu == 1 } { putmsg $chan "!fu" }     if { $rfu == 2 } { putmsg $chan "!fd" }     if { $rfu == 3 } { putmsg $chan "!fg" }     if { $rfu == 4 } { putmsg $chan "!fk" }     if { $rfu == 5 } { putmsg $chan "!fp" }     if { $rfu == 6 } { putmsg $chan "!fj" }} </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12393">wikked</a> — Sat May 24, 2014 4:06 pm</p><hr />
]]></content>
	</entry>
	</feed>
