My friend&#39;s table of local variables seems a bit simpler/straightforward while still being pretty clean?<br><br><div class="gmail_quote">On Tue, Jun 29, 2010 at 12:26 PM, Andrew Church <span dir="ltr">&lt;<a href="mailto:achurch%2Baquaria@achurch.org">achurch+aquaria@achurch.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">&gt;Well even if it&#39;s local to the script (not sure that the entire script is<br>
&gt;considered a block or not), that doesn&#39;t solve the problem of creating<br>
&gt;multiple instances of one loaded script. (which is what we want, right?)<br>
<br>
</div>Hmm, good point.  If you use loadfile() to open the script, it looks<br>
like you get a Lua function back (an anonymous function containing the<br>
script as a block), so each invocation of that function would create new<br>
local variables.  I was thinking you could use that function as the main<br>
function of a Lua thread for each entity, but then I guess you&#39;d need to<br>
add some sort of &quot;while ~dead do waitForEvent() end&quot; loop to every<br>
script and change the entire event processing system to send events to<br>
the script event loop rather than calling Lua functions directly, which<br>
sounds like a pain.  I guess you could load the file and lua_dump() it<br>
into a memory buffer, which would then be faster to load for subsequent<br>
entities because it wouldn&#39;t have to be recompiled again -- but that&#39;s<br>
probably a worse hack than what I have right now.<br>
<br>
I dunno, maybe I&#39;m trying to make the code prettier than it needs to be? (:<br>
<div><div></div><div class="h5"><br>
  --Andrew Church<br>
    <a href="mailto:achurch@achurch.org">achurch@achurch.org</a><br>
    <a href="http://achurch.org/" target="_blank">http://achurch.org/</a><br>
_______________________________________________<br>
aquaria mailing list<br>
<a href="mailto:aquaria@icculus.org">aquaria@icculus.org</a><br>
<a href="http://icculus.org/mailman/listinfo/aquaria" target="_blank">http://icculus.org/mailman/listinfo/aquaria</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Alec Holowka<br><a href="http://www.infiniteammo.ca">www.infiniteammo.ca</a><br><a href="http://www.bit-blot.com">www.bit-blot.com</a><br>