User:Lil Toady

From Multi Theft Auto: Wiki
Revision as of 14:47, 6 June 2014 by Lil Toady (talk | contribs)
Jump to navigation Jump to search
Coder.gif This user is an MTA developer

TODO:

  • OOP tostring
  • Handle vectors in CLuaArgument
  • Optimize destroyElement
  • Release packets queue after function call
  • Enhance files and timers (gc)

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,
    __call = Element.create,
    __set = {
        type = CLuaClassDefs::ReadOnly,
        health = setElementHealth,
        ...
    },
    __get = {
        type = getElementType,
        health = getElementHealth,
        ...
    },
}

VehicleMT = {
    __index = CLuaClassDefs::Index,
    __newindex = CLuaClassDefs::NewIndex,
    __class = Vehicle,
    __parent = ElementMT,
    __call = Vehicle.create,
    __set = {
        damageProof = setVehicleDamageProof
        ...
    },
    __get = {
        damageProof = isVehicleDamageProof
        ...
    },
}