createtable ex: Difference between revisions
From Onset Developer Wiki
(Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|Creates a new table and sets the metatable.}} {{FuncSyntax|createtable_ex(metatable)}} {{FuncParameters}} {{FuncParam|metatab...") |
(No difference)
|
Latest revision as of 00:19, 17 December 2019
Description
Creates a new table and sets the metatable.
Syntax
createtable_ex(metatable)
Parameters
- metatable
The metatable to set.
Return Value
- Returns a new table with the desired metatable.
Example
Timer = {}
Timer.name = "Timer"
Timer.__index = Timer
Timer.prototype = {}
Timer.prototype.__index = Timer.prototype
Timer.prototype.constructor = Timer
function Timer.new(...)
local self = createtable_ex(Timer.prototype)
self:____constructor(...)
return self
end
function Timer.prototype.____constructor(self, id)
self.id = id
print("constructor ", self.id)
end
function Timer.prototype.pause(self)
print("pause ", self.id)
end
function Timer.prototype.unpause(self)
print("unpause ", self.id)
end
function Timer.prototype.destroy(self)
print("destroy ", self.id)
end
t = Timer.new(12)
t.pause()