How do I use same function using self parameter in multiple objects?

Something like this I am looking for:

[lua]

local obj1 = display.newImage(…)

local obj2 = display.newImage(…)

obj1.name = “obj1”

obj2.name =“obj2”

local function printSelf(self)

    print(self.name)

end

obj1.printSelf() – should print “obj1”

obj2.printSelf() – shoould print “obj2”

[/lua]

If you really want to know how to do OOP in LUA, start reading this:

  1. http://www.lua.org/pil/16.html

  2. http://lua-users.org/wiki/ObjectOrientationTutorial

If you really want to know how to do OOP in LUA, start reading this:

  1. http://www.lua.org/pil/16.html

  2. http://lua-users.org/wiki/ObjectOrientationTutorial