lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have Sprite module in directory Graphics
 
local Table = require("Misc.Table")
local print = print
 
module("Graphics.Sprite")
 
Width=50
Height=50
 
function new (o)
 print(self)
 
 o = o or {}
 Table.Copy(o, self) -- copies table
 return o
end
then i call them
 
LUA_PATH = "./?.lua"
 
print(Sprite)
Sprite = require("Graphics.Sprite")
sprite = Sprite:new()
then i get
 
table: 002FBE58
nil
c:\lua\luajit: \Misc\Table.lua:8: bad argument #1 to 'pairs' (table expected, g
ot nil)
stack traceback:
        [C]: in function 'pairs'
        \Misc\Table.lua:8: in function 'Copy'
        \Graphics\Sprite.lua:13: in function 'new'
        main.lua:8: in main chunk
        [C]: ?
 
Seems that when i use : with module self isn't passed :( or am I doing something wrong? Using luajit tried both jit on and jit off.
 
I attached code to this post
 

Attachment: luatest.zip
Description: Zip compressed data