[q2x] OT: Lua questions

Brian Hook hook_l at pyrogon.com
Fri Jan 23 23:33:53 EST 2004


Okay, I sort of have Lua working kinda/sorta like how I expect it to.  
Whew.  So a couple more random questions:

1.  In terms of "making things object oriented", I've seen at least 
two different techniques.  One effectively copies from a global member 
into a new table.

classdef = {}

function classdef:create()
   local new = {}
   for i, v in classdef do
      new[ i ] = v[ i ]
   end
   return new
end

Or something like that.  Then there's the other mechanism that 
involves copying the metatable __index.  Is there a particular 
advantage of one over the other?

2.  This is a bit more complicated, but I wonder what the effect of 
running a script multiple times is?  Specifically, if I have a 
monster.lua, I load it, run it, then later I edit it and reload it, is 
there expected behaviour?

Yeah yeah, I should go join lua-l again...

Brian





More information about the q2x mailing list