DGS OOP Class: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 2: | Line 2: | ||
==Structure== | ==Structure== | ||
When using DGS [[OOP]], DGS objects | When using DGS [[OOP]], DGS objects to be operated are no longer elements, instead, they will be tables ( table is the only type whose call methods can be defined in lua ) . | ||
Here is the structure of DGS OOP Object: | Here is the structure of DGS OOP Object: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Revision as of 07:42, 15 November 2018
DGS provides not only POP ( Procedure Oriented Programming ) but also OOP ( Object Oriented Programming ). This page introduces OOP of dgs.
Structure
When using DGS OOP, DGS objects to be operated are no longer elements, instead, they will be tables ( table is the only type whose call methods can be defined in lua ) . Here is the structure of DGS OOP Object:
DGSDxObject = { DGSElement = DGSElement -- The actual dgs element function1, function2, ... }
- The built-in functions are non-modifiable
- Any variable of the table are get/set via dgsSetProperty/dgsGetProperty ( Exclude DGSElement )
- After importing DGS OOP Class, there is a table called : DGSClass
Get Started
Instead of using
label = exports.dgs:dgsCreateLabel(0, 0, 0.5, 0.1, "text", true)
DGS = exports.dgs label = DGS:dgsCreateLabel(0,0,0.5,0.1,"text",true)
loadstring(exports.dgs:dgsImportFunction())()-- load functions label = dgsCreateLabel(0,0,0.5,0.1,"text",true) --create a label
We provides Object Oriented Programming
loadstring(exports.dgs:dgsImportOOPClass())()-- load OOP class window = DGSClass:createWindow(0,0,0.5,0.1,"test",true) --create a window with oop label = window:createLabel(0,0,1,1,"label",true) --create a label inside the window label.text = "DGS OOP Test" --set text