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

	<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>2007-06-28T17:22:47-04:00</updated>

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

		<entry>
		<author><name><![CDATA[StarLion]]></name></author>
		<updated>2007-06-28T17:22:47-04:00</updated>

		<published>2007-06-28T17:22:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=73985#p73985</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=73985#p73985"/>
		<title type="html"><![CDATA[lreplace to single value...?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=73985#p73985"><![CDATA[
okay, nevermind, i'm a doofus. Forgot the $ in front of the 'cardcounts' in the lreplace...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7134">StarLion</a> — Thu Jun 28, 2007 5:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[StarLion]]></name></author>
		<updated>2007-06-28T13:29:33-04:00</updated>

		<published>2007-06-28T13:29:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=73979#p73979</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=73979#p73979"/>
		<title type="html"><![CDATA[lreplace to single value...?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=73979#p73979"><![CDATA[
Well, let me review.<br>Here's the proc chain that's being called:<br><div class="codebox"><p>Code: </p><pre><code>proc startgame {nick host hand chan text} {  global players gamestate hands coloring coloringend deckstring gamechan  if {$chan == $gamechan &amp;&amp; $gamestate == 2 &amp;&amp; [llength $players] &gt; 1} {     set gamestate 3     putquick "PRIVMSG $chan : $nick has started the game! Dealing out the cards..."     repopdeck     for { set walker 0 } { $walker &lt; [llength $players] } { incr walker } {        draw 7 $walker        set output "Your Cards:"        foreach card $hands($walker) {           append output " \003"           append output [lindex $coloring [lsearch $deckstring $card]] $card           append output "\003"        }        putquick "NOTICE [lindex $players $walker] : $output"     }     nextplayer  }}proc draw {number target} {  global cardcounts hands deck decktotal deckstring  for { set start 0 } { $start &lt; $number } { incr start } {    set flag 0    if { $decktotal == 0 } { repopdeck }    while { $flag == 0 } {      set testcard [rand 50]      if { [lindex $deck $testcard] &lt; 4 } { set flag 1 }     }    set newdeckc [lindex $deck $testcard]    incr newdeckc 1    set deck [lreplace $deck $testcard $testcard $newdeckc]    set newcardc [lindex $cardcounts $target]    putlog "Test Node: Target: $target Cardcountvalue: $newcardc"    incr newcardc 1    set cardcounts [lreplace cardcounts $target $target $newcardc]    putlog "Replace Node: Attempt: $newcardc Actual: [lindex $cardcounts $target]"    lappend hands($target) [lindex $deckstring $testcard]  }  incr decktotal -1}</code></pre></div>(Note: The putlogs are my attempts at debugging)<br><br>The initial values are:<br>$cardcounts {0 0}<br>$deck : A list of 50 zeros.<br>$hands:  An array of lists, referenced numerically ($hands(0) {})<br><br>After the first walk through StartGame's loop, $cardcounts has become the static value 7 (no longer a list of two items). The script then promptly borks as the second loop goes into draw, and does this:<div class="codebox"><p>Code: </p><pre><code>    set newdeckc [lindex $deck $testcard]    incr newdeckc 1</code></pre></div>resulting in the error: <div class="codebox"><p>Code: </p><pre><code>Currently: expected integer but got ""Currently:     while executingCurrently: "incr newcardc 1"Currently:     (procedure "draw" line 15)Currently:     invoked from withinCurrently: "draw 7 $walker"Currently:     (procedure "startgame" line 9)Currently:     invoked from withinCurrently: "startgame $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"</code></pre></div>Oddly, it works correctly on the deck..... but the cardcounts screw up <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7134">StarLion</a> — Thu Jun 28, 2007 1:29 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[StarLion]]></name></author>
		<updated>2007-06-28T12:56:08-04:00</updated>

		<published>2007-06-28T12:56:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=73978#p73978</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=73978#p73978"/>
		<title type="html"><![CDATA[lreplace to single value...?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=73978#p73978"><![CDATA[
i've tried <div class="codebox"><p>Code: </p><pre><code>set cardcounts [lreplace $cardcounts $target $target $newcardc]</code></pre></div>but this makes $cardcounts a local variable, and destroys it (AND the global copy) at end of proc... which is very odd to me considering $cardcounts is locally created using <div class="codebox"><p>Code: </p><pre><code>global cardcounts</code></pre></div> ...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7134">StarLion</a> — Thu Jun 28, 2007 12:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-06-28T10:49:19-04:00</updated>

		<published>2007-06-28T10:49:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=73976#p73976</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=73976#p73976"/>
		<title type="html"><![CDATA[lreplace to single value...?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=73976#p73976"><![CDATA[
lreplace expects the first variable to be a list, and will return a modified list.<br>Try saving the output of lreplace, and you'll find it working like a charm...<br><br>You'll find a few good examples at the manpage for <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/lreplace.htm" class="postlink">lreplace</a> aswell.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jun 28, 2007 10:49 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[StarLion]]></name></author>
		<updated>2007-06-28T10:42:49-04:00</updated>

		<published>2007-06-28T10:42:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=73973#p73973</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=73973#p73973"/>
		<title type="html"><![CDATA[lreplace to single value...?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=73973#p73973"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>    set newcardc [lindex $cardcounts $target]    incr newcardc 1    lreplace $cardcounts $target $target $newcardc    putlog "Replace Node: Attempt: $newcardc Actual: [lindex $cardcounts $target]"</code></pre></div>This code outputs "Replace Node: Attempt: 1 Actual: 0"... indicating my lreplace didnt actually DO anything... what am i doing wrong?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7134">StarLion</a> — Thu Jun 28, 2007 10:42 am</p><hr />
]]></content>
	</entry>
	</feed>
