Lua objects as arguments
Posted: Fri Jul 11, 2008 6:42 pm
How do you pass an object from one function into another?
Here is my basic object:
I would like to pass one "Position" from one function into another but I am not sure as to how you do it?
Sorry, I am new to Lua.
Here is my basic object:
Code: Select all
-- Very basic position object for now
Position = {}
Position_mt = {}
function Position:new(Temp_x, Temp_y)
Temp_x = Temp_x or 0
Temp_y = Temp_y or 0
newPosition = { x = Temp_x, y = Temp_y }
return setmetatable(newPosition, Position_mt)
end
Position_mt.__index = Position
Sorry, I am new to Lua.