Advertisement
LuaWeaver

wOOP 0.6.0 docs

Nov 30th, 2012
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Docs for wOOP 0.6.0
  2.  
  3. METHODS DO NOT USE A COLON.
  4. THEY USE A .
  5. THE SELF VARIABLE IS 'IMPLIED'
  6.  
  7. Global functions
  8. wOOPupdate(nil) -- For events. Updates all events.
  9. class(STRING className, [STRING extends], TABLE data) -- Create a new class. className is the name of the class. extends is the optional classname it inherits from. data is all the contents.
  10.  
  11. Global classes
  12.  
  13. CLASS base(nil) -- The base class for all objects. Every object is an extension of this.
  14. Class props
  15. STRING className -- the classname
  16. TABLE __settings -- the settings of the class
  17. TABLE __omt -- the object metatable
  18. TABLE __mt -- the metatable
  19. Class methods
  20. isA(STRING className) -- checks if the class if or extends the className
  21.  
  22. CLASS event(FUNCTION condition) -- An event. condition is a function which is run every frame and if true will run the callback function.
  23. Class props
  24. BOOLEAN _connected -- Whether a callback is selected.
  25. Class methods
  26. connect(FUNCTION callback) -- Runs this function every time the condition is met.
  27. disconnect(nil) -- Remvoes the callback.
  28.  
  29.  
  30. Class structure
  31.  
  32. class "exampleClass" "base" --base is automatically set if not specified
  33. {
  34. --PROPS START HERE
  35. __x=0, --The __ makes this a private value
  36. __y=0,
  37.  
  38. _magnitude=0,
  39.  
  40. --METHODS START HERE
  41. slide=
  42. function(x,y)
  43. self.__x=self.__x+x --Private and read only values can be changed using methods
  44. self.__y=self.__y+y
  45. self._magnitude=math.sqrt(self.__x^2+self.__y^2) --distance formula (magnitude)
  46. end,
  47.  
  48. coords=
  49. function()
  50. return self.__x,self.__y
  51. end,
  52.  
  53. --EVENTS START HERE
  54. origin =
  55. event function(oldSelf,newSelf) --oldSelf : THE OBJECT ONE FRAME AGO newSelf : THE CURRENT OBJECT
  56. if newSelf.x==0 and newSelf.y==0 then
  57. return true
  58. end
  59. end,
  60.  
  61. --CLASS SETUP STARTS HERE
  62. __settings= --Settings
  63. {
  64. new= --Constructor
  65. function(x,y)
  66. return {x=x,y=y}
  67. end
  68. },
  69. __omt=
  70. {
  71. __tostring=="example"
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement