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

	<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>2011-03-11T19:57:15-04:00</updated>

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

		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-11T19:57:15-04:00</updated>

		<published>2011-03-11T19:57:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96457#p96457</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96457#p96457"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96457#p96457"><![CDATA[
ty, gonna try that<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Fri Mar 11, 2011 7:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-03-11T19:48:06-04:00</updated>

		<published>2011-03-11T19:48:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96456#p96456</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96456#p96456"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96456#p96456"><![CDATA[
So you were indeed applying the same kind of binding to the pub_bender proc. Thus, you'll either have to re-write pub_bender, or write a wrapper, to dig out the number from the whole line of text.<br>The simplest would probably be to write a wrapper, that actually don't bother with digging for the number, but use the random-line operation:<div class="codebox"><p>Code: </p><pre><code>bind pubm -|- "*!trigger" pubm_benderproc pubm_bender {nick host handle channel text} {  pub_bender $nick $host $handle $channel ""}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Mar 11, 2011 7:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-11T19:42:23-04:00</updated>

		<published>2011-03-11T19:42:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96455#p96455</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96455#p96455"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96455#p96455"><![CDATA[
if i do pubm on it, it'll do<br><br>&lt;..&gt; &lt;trigger&gt;<br> -...-  enter a number pitiful human! (notice)<br><br>the whole time, and only that<br><br>yea, trying to learn on the trigger thing, different script tho<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Fri Mar 11, 2011 7:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-03-11T18:05:48-04:00</updated>

		<published>2011-03-11T18:05:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96454#p96454</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96454#p96454"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96454#p96454"><![CDATA[
I can't see why the binding I proposed would interfere with bender_quotes, as they don't overlap.<br><br>If you were to apply the same kind of binding to the bender_quotes script however, you would have to rewrite the pub_bender proc as "arg" would contain the whole line of text (including the !game trigger), rather than the text following the first word.<br><br>With the simple scripts proposed in this thread, that wouldn't be an issue, since they don't care of the content of "text", though.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Mar 11, 2011 6:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-11T17:56:18-04:00</updated>

		<published>2011-03-11T17:56:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96453#p96453</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96453#p96453"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96453#p96453"><![CDATA[
yea, ty, but this pubm is messing the script up somehow, talking about the <a href="http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&amp;id=1689" class="postlink">http://www.egghelp.org/cgi-bin/tcl_arch ... ad&amp;id=1689</a> by oldsoldier here, dunno what is wrong there<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Fri Mar 11, 2011 5:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-03-11T16:38:42-04:00</updated>

		<published>2011-03-11T16:38:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96452#p96452</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96452#p96452"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96452#p96452"><![CDATA[
Wildcards such as * and % only works with the matching version of the binding (such as pubm for public channel chat and msgm for private messages). The proper binding would in this case be as follows:<div class="codebox"><p>Code: </p><pre><code>bind pubm -|- "*!game*" game</code></pre></div>Edit: Fixed minor typo<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Mar 11, 2011 4:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-11T16:34:38-04:00</updated>

		<published>2011-03-11T16:34:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96451#p96451</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96451#p96451"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96451#p96451"><![CDATA[
just another question for you pro's, would be cool if you could help me there. is it possible to set the trigger so that it will function (in this case) to not only "!game", but also to look in whole sentences like "why dont you type !game while we're at it"<br><br>i've tried:<br><br> bind pub  -|- * !game game<br> bind pub  -|- "* !game" game<br> bind pub  -|- *!game* game<br> bind pub  -|- "*!game*" game<br> bind pubm  -|- "* !game" game<br> bind pubm  -|- "% !game" game<br><br>and so on, but nothing works...<br><br>i.e. "*!game*" will trigger on *!game* only but not on "is this a !game"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Fri Mar 11, 2011 4:34 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2011-03-04T10:19:11-04:00</updated>

		<published>2011-03-04T10:19:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96296#p96296</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96296#p96296"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96296#p96296"><![CDATA[
In core Tcl it is the mathamatical expression rand(), used together with the command expr to return a random floating point value between 0 and 1.<br><br>The command [rand &lt;limit&gt;] only exists in Eggdrop Tcl to return a random integer between 0 and &lt;limit&gt;-1<br><br>Hence if you are scripting for Eggdrop, either is allowed.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Fri Mar 04, 2011 10:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2011-03-03T15:27:31-04:00</updated>

		<published>2011-03-03T15:27:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96287#p96287</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96287#p96287"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96287#p96287"><![CDATA[
While in other coding languages it's rand() in TCL it's [rand]. Also, notice the [ and ] that translate in to calling the function of whatever you got inside.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Mar 03, 2011 3:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-03T14:22:11-04:00</updated>

		<published>2011-03-03T14:22:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96286#p96286</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96286#p96286"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96286#p96286"><![CDATA[
ty, will try it this way then. i thought the "rand()" is calling the function, but [rand 7] looks much more handy aswell as the "switch" cmd..<br><br>kudos<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Thu Mar 03, 2011 2:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2011-03-03T03:07:04-04:00</updated>

		<published>2011-03-03T03:07:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96282#p96282</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96282#p96282"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96282#p96282"><![CDATA[
If you want to trigger a command upon !game then you will need 'bind pub' not 'bind pubm'. By using 'pub' instead the:<div class="codebox"><p>Code: </p><pre><code>if {[string equal -nocase "#channel:!game" $text]} {random_int} </code></pre></div>can be removed. Instead of a bunch of 'if' and 'elseif' you should use <a href="http://www.tcl.tk/man/tcl8.5/TclCmd/switch.htm" class="postlink">switch</a>. In order to get a random number from 1 to 7 (both included) not from 0 to 6<br>you need to use [expr [rand 7] +1] to have. Also, the correct definition of a proc is:<div class="codebox"><p>Code: </p><pre><code>proc myproc {variables} {# my stuff}</code></pre></div>Notice the { and }.<br>Anyway, here's a 'pub' code:<div class="codebox"><p>Code: </p><pre><code>bind pub  o|* !game pub:gameproc pub:game {nick uhost hand chan text} {  switch -- [expr [rand 7] +1] {    1 {      putserv "PRIVMSG #channel :$nick plays TXT1!"    }    2 {      putserv "PRIVMSG #channel :$nick plays TXT2!"    }    3 {      putserv "PRIVMSG #channel :$nick plays TXT3!"    }    4 {      putserv "PRIVMSG #channel :$nick plays TXT4!"    }    5 {      putserv "PRIVMSG #channel :$nick plays TXT5!"    }    6 {      putserv "PRIVMSG #channel :$nick plays TXT6!"    }    7 {      putserv "PRIVMSG #channel :$nick plays TXT7!"    }  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Thu Mar 03, 2011 3:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-02T22:42:09-04:00</updated>

		<published>2011-03-02T22:42:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96280#p96280</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96280#p96280"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96280#p96280"><![CDATA[
so...<br><div class="codebox"><p>Code: </p><pre><code>bind pubm  o|* "!game" gameproc game {nick host hand chan text}{ if {[string equal -nocase "#channel:!game" $text]} {random_int} #or add set var text here and return $text or can i leave it at all??}proc random_int { } { set myrand [expr int(rand() * 7)] return $myrand}{#if     {$myrand == 0} {set $myrand i+1} //&lt;-needed??????????if     {$myrand == 1} {putserv "PRIVMSG #channel:$nick plays TXT1!"}elseif {$myrand == 2} {putserv "PRIVMSG #channel:$nick plays TXT2!"}elseif {$myrand == 3} {putserv "PRIVMSG #channel:$nick plays TXT3!"}elseif {$myrand == 4} {putserv "PRIVMSG #channel:$nick plays TXT4!"}elseif {$myrand == 5} {putserv "PRIVMSG #channel:$nick plays TXT5!"}elseif {$myrand == 6} {putserv "PRIVMSG #channel:$nick plays TXT6!"}elseif {$myrand == 7} {putserv "PRIVMSG #channel:$nick plays TXT7!"}#endif ???} </code></pre></div>...better?<br><br>and the if one is due to the output, it has to be a txt-msg instead of the no. out of the variable<br><br>and regarding the first error, i've read:<br><br>BIND [type] [Flags] [Event] [NameofProc]<br><br>edit:<br><blockquote class="uncited"><div>I took the liberty of posting your "Tcl script" on a pastebin that has a static Tcl syntax checker and here you can see the result of that (the errors above the code): <a href="http://paste.tclhelp.net/?id=8p2" class="postlink">http://paste.tclhelp.net/?id=8p2</a></div></blockquote>i don't get <a href="http://paste.tclhelp.net/?id=8p2" class="postlink">this static tcl checker</a> -&gt; leaving most of the braces, which i thought were needed from what i've read, removes some errors. guess i have to think over the syntax once again<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Wed Mar 02, 2011 10:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-02T22:28:23-04:00</updated>

		<published>2011-03-02T22:28:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96279#p96279</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96279#p96279"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96279#p96279"><![CDATA[
yea, will do. ty, was trying to get my mirc script into tcl and as i've said i've never worked with tcl scripts, so u are right. but calling it "spaghetticode" is veeeery nice of u <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Wed Mar 02, 2011 10:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[thommey]]></name></author>
		<updated>2011-03-02T21:48:57-04:00</updated>

		<published>2011-03-02T21:48:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96278#p96278</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96278#p96278"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96278#p96278"><![CDATA[
<ol style="list-style-type:decimal"><li> bind pubm doesn't work that way, reread <a href="http://www.eggheads.org/support/egghtml/1.6.20/tcl-commands.html#binda_pubm" class="postlink">the documentation about it</a>.. the mask is matched against "#chan text", not against "text"</li><li> $text isn't set in your proc, you called the last variable $rest</li><li> defining a proc in a proc is almost always wrong, you wouldn't do that in mircscript either, are you sure you know mircscript?</li><li> no need to "global myrand", a local variable is sufficient and better style if you store the return value of random_int</li><li> your if control structure seems to be weird, it generates the id only if !game is equal to $text but the rest is evaluated in any case</li><li> why not just .. "PRIVMSG #channel :$nick plays $myrand" instead of that spaghetticode?</li><li> you violate fundamental <a href="http://wiki.tcl.tk/dodekalogue" class="postlink">Tcl syntax</a> with your elseif statements and your bracing style (brace = {})</li></ol>In the end, my advice is to read a tcl tutorial, here's a list:<br><br><span style="text-decoration:underline">Tcl tutorials:</span><ul><li><a href="http://www.invece.org/tclwise" class="postlink">http://www.invece.org/tclwise</a></li><li><a href="http://en.wikibooks.org/wiki/Programming:Tcl" class="postlink">http://en.wikibooks.org/wiki/Programming:Tcl</a></li><li><a href="http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html" class="postlink">http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html</a></li><li><a href="http://wiki.tcl.tk/10259" class="postlink">http://wiki.tcl.tk/10259</a></li><li><a href="http://tcl.projectforum.com/young/22" class="postlink">http://tcl.projectforum.com/young/22</a></li></ul><span style="text-decoration:underline">Eggdrop specific:</span><ul><li><a href="http://suninet.the-demon.de/" class="postlink">http://suninet.the-demon.de/</a></li><li><a href="http://johoho.eggheads.org/eggdrop/other/guide2tcl.html" class="postlink">http://johoho.eggheads.org/eggdrop/other/guide2tcl.html</a></li></ul>I took the liberty of posting your "Tcl script" on a pastebin that has a static Tcl syntax checker and here you can see the result of that (the errors above the code): <a href="http://paste.tclhelp.net/?id=8p2" class="postlink">http://paste.tclhelp.net/?id=8p2</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9830">thommey</a> — Wed Mar 02, 2011 9:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[jeffo]]></name></author>
		<updated>2011-03-02T21:41:20-04:00</updated>

		<published>2011-03-02T21:41:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96277#p96277</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96277#p96277"/>
		<title type="html"><![CDATA[1st tcl script - text event trigger - help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96277#p96277"><![CDATA[
hi all,<br><br>as u've seen in the topic it's my first tcl one (did mirc scripts already).<br><br>here's my code so far:<br><div class="codebox"><p>Code: </p><pre><code>bind pubm  o|* "!game" gameproc game {nick uhost hand chan rest}{ if {[string equal -nocase "!game" $text]} {random_int} proc random_int { } {            global myrand            set myrand [expr int(rand() * 7)]            return $myrand            }{#if     {$myrand == 0} {set $myrand i+1} //&lt;-needed??????????if     {$myrand == 1} {putserv "PRIVMSG #channel:$nick plays 1!"}elseif {$myrand == 2} {putserv "PRIVMSG #channel:$nick plays 2!"}elseif {$myrand == 3} {putserv "PRIVMSG #channel:$nick plays 3!"}elseif {$myrand == 4} {putserv "PRIVMSG #channel:$nick plays 4!"}elseif {$myrand == 5} {putserv "PRIVMSG #channel:$nick plays 5!"}elseif {$myrand == 6} {putserv "PRIVMSG #channel:$nick plays 6!"}elseif {$myrand == 7} {putserv "PRIVMSG #channel:$nick plays 7!"}}}</code></pre></div>as u can see, it shall trigger an "!game" from ops and randomnize the output in a public message.<br><br>as it is my first tcl, i'm not sure if i got the syntax right, probably/most likely not. so help a newbie here pls.<br><br>thx in advance<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11585">jeffo</a> — Wed Mar 02, 2011 9:41 pm</p><hr />
]]></content>
	</entry>
	</feed>
