jesterxl

Lua Circle class scope stuff

Mar 13th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. MyCircle = {}
  2.  
  3. function MyCircle:new()
  4.  
  5.     local circle = display.newCircle(0, 0, 20)
  6.  
  7.     function circle:uno()
  8.         print("circle uno")
  9.     end
  10.  
  11.     local function dos()
  12.         print("circle dos")
  13.     end
  14.  
  15.     function tres()
  16.         print("circle tres")
  17.     end
  18.  
  19.     print("uno:", uno)
  20.     print("dos:", dos)
  21.     print("tres:", tres)
  22.  
  23.     return circle
  24.  
  25.    
  26.  
  27. end
  28.  
  29. print("uno:", uno)
  30.     print("dos:", dos)
  31.     print("tres:", tres)
  32.    
  33. return MyCircle
  34.  
  35. -- then in main.lua
  36.  
  37. function showProps(o)
  38.     print("-- showProps --")
  39.     print("o: ", o)
  40.     for key,value in pairs(o) do
  41.         print("key: ", key, ", value: ", value);
  42.     end
  43.     print("-- end showProps --")
  44. end
  45.  
  46.  
  47.  
  48. require "MyCircle"
  49. local circle = MyCircle:new()
  50. print("** _G props **")
  51. showProps(_G)
  52. print("** MyCircle props **")
  53. showProps(MyCircle)
  54. print("** circle props **")
  55. showProps(circle)
Advertisement
Add Comment
Please, Sign In to add comment