Wednesday, August 31, 2005

Still playing with Lua

Currently I'm working on functions that mess with strings and will hopefully in the future help my npcs have interesting things to say. This lead me to a problem where I didn't want to use references in Lua through gamedev.net I found the solution. If anyone else has a similar problem here's the clone code I'm using:


function Clone(t)
if type(t) ~= "table" then return t end
local b = {}
table.foreach(t, function(k,v) b[k]= Clone(v) end)
return b
end


This is ever so slighly modified from something I grabbed out of the Lua mailing list. The basic problem was I wanted to have a copy of the varaible rather that editing its reference. I wanted the lua argument to be constant, remain unchanged, through out the function.

As always my bookmarks have grown. I watched the first video at MIT for the linear algebra course. Yes a free online maths course in Linear Algebra - perfect for writing 3D games. Cool no? Maybe because this guy is a better a lecturer or I was watching out of free will - but for the first time - matrix vector multiplication has stuck with me. Previously I just memorized the method for exams and promptly forgot it as soon as they were over. Anyway I intend to keep checking them out! They're very good I recommend them!

That's how it's going, my weekends going to be busy but maybe Sunday I'll be able to get some game time.

No comments: