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

	<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>2006-08-09T17:27:08-04:00</updated>

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

		<entry>
		<author><name><![CDATA[darton]]></name></author>
		<updated>2006-08-09T17:27:08-04:00</updated>

		<published>2006-08-09T17:27:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65330#p65330</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65330#p65330"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65330#p65330"><![CDATA[
I have shortened the script above a little bit <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br>So its not the $nick directly who says !afk. The bot who is $nick reproduces everything from a game, so there are people in the game who type !afk. So its [lindex [split $arg] 0] who says !afk.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7270">darton</a> — Wed Aug 09, 2006 5:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-08-09T17:19:52-04:00</updated>

		<published>2006-08-09T17:19:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65329#p65329</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65329#p65329"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65329#p65329"><![CDATA[
@krimson: Ahh... very true, $nick is the desired nick, while $botnick is the actual.. keep mixing those up all the time :/  *bows before master*<br><br>@darton: Then there would be no use to make any variables global at all, go with krimson's example instead or put the checks directly inside the first proc...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Aug 09, 2006 5:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darton]]></name></author>
		<updated>2006-08-09T16:59:11-04:00</updated>

		<published>2006-08-09T16:59:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65327#p65327</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65327#p65327"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65327#p65327"><![CDATA[
Thank you all for your answers.<br>By the way, its not a bot who types !afk, its a normal user and if that one types !afk my bot says that that user ($nick) is afk.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7270">darton</a> — Wed Aug 09, 2006 4:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[krimson]]></name></author>
		<updated>2006-08-09T16:24:43-04:00</updated>

		<published>2006-08-09T16:24:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65326#p65326</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65326#p65326"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65326#p65326"><![CDATA[
it's true that his first post was not so clear, but still, for that matter you'd need to use $botnick instead of $nick<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7663">krimson</a> — Wed Aug 09, 2006 4:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-08-09T16:09:58-04:00</updated>

		<published>2006-08-09T16:09:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65325#p65325</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65325#p65325"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65325#p65325"><![CDATA[
1. Depends on the purpose of the proc.. in this case, botaway would indicate it's this bot, hence requiring a nick to be supplied externally would be confusing. If the objective were to check a random nick, you'd be correct tho.<br>Considdering the ambiguos nature of darton's original code, I'd guess both are equally correct given it's interpretation of that code...<br><br>2. True. Just keep a habit of enclosing variable names with {} whenever it is adjacent to any non-whitespace character (Rather do it excessively, rather than forgetting it when really needed)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Aug 09, 2006 4:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[krimson]]></name></author>
		<updated>2006-08-09T15:55:59-04:00</updated>

		<published>2006-08-09T15:55:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65324#p65324</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65324#p65324"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65324#p65324"><![CDATA[
here are some tips:<br><br>1. don't use global nick, you'd be better off using an argument for proc botaway instead<br><br>2. you don't have to use ${nick} there, you use that when you have any non-space char right after the var, and don't want it to get mixed up with something else<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7663">krimson</a> — Wed Aug 09, 2006 3:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-08-09T15:40:51-04:00</updated>

		<published>2006-08-09T15:40:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65322#p65322</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65322#p65322"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65322#p65322"><![CDATA[
Guess that's why one should never code when dead-tired (or quite intoxicated)   <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <br>(learned that the hard way myself...)<br><br>Tho while we're at it, might aswell throw in something like this<div class="codebox"><p>Code: </p><pre><code>proc botaway { global nick return [expr {[string equal -nocase bla $nick] || [string equal -nocase blabla $nick]}]}proc afk {n u ho ha c t} { global nick if {[botaway]} {  puthelp "PRIVMSG $c :${nick} is AFK" }}</code></pre></div>Anyway, what still puzzles me is this: is it the user typing !afk, or the bot, that we are supposed to test against those afk-nicks?<br>I've never known an eggdrop to be afk sorta.. but then again, why would an user need a bot to tell him/her wether (s)he's afk.. (and quite limited to two possible nicks)<br><br>But as it seems darton is'nt putting much more info into this thread, I guess we'll never know  *shrug*<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Aug 09, 2006 3:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[krimson]]></name></author>
		<updated>2006-08-09T15:38:12-04:00</updated>

		<published>2006-08-09T15:38:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65321#p65321</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65321#p65321"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65321#p65321"><![CDATA[
that's no prob :P just wanted to make sure the info is recieved the right way ;)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7663">krimson</a> — Wed Aug 09, 2006 3:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[KrzychuG]]></name></author>
		<updated>2006-08-09T15:11:04-04:00</updated>

		<published>2006-08-09T15:11:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65320#p65320</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65320#p65320"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65320#p65320"><![CDATA[
<blockquote class="uncited"><div>if you used an argument when declaring the procs, you must use it when calling them too<br>]</div></blockquote>Of course you're right. It was late, i was tired :)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3672">KrzychuG</a> — Wed Aug 09, 2006 3:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[krimson]]></name></author>
		<updated>2006-08-09T04:21:59-04:00</updated>

		<published>2006-08-09T04:21:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65307#p65307</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65307#p65307"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65307#p65307"><![CDATA[
if you used an argument when declaring the procs, you must use it when calling them too<br><div class="codebox"><p>Code: </p><pre><code>proc bla { nick } { return [string equal -nocase bla $nick] }proc blabla { nick } { return [string equal -nocase blabla $nick] }bind pubm - "*!afk*" afkproc afk {nick host hand chan arg} { if {[bla $nick] || [blabla $nick]} {  putquick "PRIVMSG $chan :$nick is AFK." }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7663">krimson</a> — Wed Aug 09, 2006 4:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[KrzychuG]]></name></author>
		<updated>2006-08-08T14:59:51-04:00</updated>

		<published>2006-08-08T14:59:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65285#p65285</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65285#p65285"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65285#p65285"><![CDATA[
Can't you convert those global variables to procedures? I don't think you can use variable like you defined.<br><div class="codebox"><p>Code: </p><pre><code>proc bla { nick } { return [string equal -nocase bla $nick] }proc blabla { nick } { return [string equal -nocase blabla $nick] }bind pubm - "*!afk*" afk proc afk {nick host hand chan arg} {  if {[bla] || [blabla]} {   putquick "PRIVMSG $chan :$nick is AFK."  } }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3672">KrzychuG</a> — Tue Aug 08, 2006 2:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-08-08T08:54:58-04:00</updated>

		<published>2006-08-08T08:54:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65271#p65271</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65271#p65271"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65271#p65271"><![CDATA[
As I remember, $nick is a reserved variable, "always" set to whatever nick your bot currently uses..<br>Hav'nt dug into the source in a while, but I'd guess it's not set during startup..<br>I also get this distict feeling darton expects bla and blabla to be updated as soon as nick is changed... which is most definetly not the case, all "global" does is to link the local (function-instance) variable to the global one (ie making bla and blabla readable from within the function even tho they exist outside).<br><br>It feels like he actually wants to do some variable tracing (man n trace), although coding event-driven tcl isn't that pretty in eggies as I recall...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Aug 08, 2006 8:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[krimson]]></name></author>
		<updated>2006-08-08T03:23:32-04:00</updated>

		<published>2006-08-08T03:23:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65266#p65266</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65266#p65266"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65266#p65266"><![CDATA[
@darton: the reason why the code in your first post won't work is because (probably) you didn't set $nick before setting $bla and $blabla. this is the reason why you should use both vars inside your procs<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7663">krimson</a> — Tue Aug 08, 2006 3:23 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2006-08-07T17:43:30-04:00</updated>

		<published>2006-08-07T17:43:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65242#p65242</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65242#p65242"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65242#p65242"><![CDATA[
This is what I'd suggest... Assuming from your first post that you wish to check wether the bot is afk or not, and reply "&lt;yournick&gt; is AFK" if so...<div class="codebox"><p>Code: </p><pre><code>proc {unick host hand chan text} { global nick if {[string equal -nocase "bla" $nick] || [string equal -nocase "blabla" $nick]} {  putquick "PRIVMSG $chan :$unick is AFK" }}</code></pre></div>The load won't increase much, unless you plan to call this 10 times a second or such...<br><br>Also, my first question in my last post should actually have been: do you update those variables anywhere _else_ in the script while the bot runs<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Aug 07, 2006 5:43 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[darton]]></name></author>
		<updated>2006-08-07T17:38:01-04:00</updated>

		<published>2006-08-07T17:38:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=65241#p65241</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=65241#p65241"/>
		<title type="html"><![CDATA[global variables don't work]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=65241#p65241"><![CDATA[
Yes I update it at any time with "global bla blabla". But does that increase load? I think there is no difference if I write "if {$bla || $blabla}" or "if {[string equal -nocase $blabla $nick]}"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7270">darton</a> — Mon Aug 07, 2006 5:38 pm</p><hr />
]]></content>
	</entry>
	</feed>
