User:Lil Toady: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
===OOP Metatable Structure=== | ===OOP Metatable Structure=== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Exposed to global environment | |||
Element = { | Element = { | ||
create = createElement, | create = createElement, | ||
Line 21: | Line 22: | ||
} | } | ||
-- Hidden in lua registry, applied to userdata | |||
ElementMT = { | ElementMT = { | ||
__index = CLuaClassDefs::Index, | __index = CLuaClassDefs::Index, |
Revision as of 19:59, 26 April 2013
TODO:
- OOP tostring
- OOP vectors
- Optimize destroyElement
- Release packets queue after function call
OOP Metatable Structure
-- Exposed to global environment Element = { create = createElement, setPosition = setElementPosition, ... } Vehicle = { create = createVehicle, setColor = setVehicleColor, ... } -- Hidden in lua registry, applied to userdata ElementMT = { __index = CLuaClassDefs::Index, __newindex = CLuaClassDefs::NewIndex, __class = Element, __set = { type = CLuaClassDefs::ReadOnly, health = setElementHealth, ... }, __get = { type = getElementType, health = getElementHealth, ... }, } VehicleMT = { __index = CLuaClassDefs::Index, __newindex = CLuaClassDefs::NewIndex, __class = Vehicle, __parent = ElementMT, __set = { damageProof = setVehicleDamageProof ... }, __get = { damageProof = isVehicleDamageProof ... }, }