Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Docs for wOOP 0.6.0
- METHODS DO NOT USE A COLON.
- THEY USE A .
- THE SELF VARIABLE IS 'IMPLIED'
- Global functions
- wOOPupdate(nil) -- For events. Updates all events.
- 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.
- Global classes
- CLASS base(nil) -- The base class for all objects. Every object is an extension of this.
- Class props
- STRING className -- the classname
- TABLE __settings -- the settings of the class
- TABLE __omt -- the object metatable
- TABLE __mt -- the metatable
- Class methods
- isA(STRING className) -- checks if the class if or extends the className
- CLASS event(FUNCTION condition) -- An event. condition is a function which is run every frame and if true will run the callback function.
- Class props
- BOOLEAN _connected -- Whether a callback is selected.
- Class methods
- connect(FUNCTION callback) -- Runs this function every time the condition is met.
- disconnect(nil) -- Remvoes the callback.
- Class structure
- class "exampleClass" "base" --base is automatically set if not specified
- {
- --PROPS START HERE
- __x=0, --The __ makes this a private value
- __y=0,
- _magnitude=0,
- --METHODS START HERE
- slide=
- function(x,y)
- self.__x=self.__x+x --Private and read only values can be changed using methods
- self.__y=self.__y+y
- self._magnitude=math.sqrt(self.__x^2+self.__y^2) --distance formula (magnitude)
- end,
- coords=
- function()
- return self.__x,self.__y
- end,
- --EVENTS START HERE
- origin =
- event function(oldSelf,newSelf) --oldSelf : THE OBJECT ONE FRAME AGO newSelf : THE CURRENT OBJECT
- if newSelf.x==0 and newSelf.y==0 then
- return true
- end
- end,
- --CLASS SETUP STARTS HERE
- __settings= --Settings
- {
- new= --Constructor
- function(x,y)
- return {x=x,y=y}
- end
- },
- __omt=
- {
- __tostring=="example"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement