Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Weird Lua OOP Lib
-- -- Go to the bottom for a sample -- local class; do local function copyTable(tbl) if type(tbl) ~= "table" then return tbl end local newTable = {} for i, v in pairs(tbl) do newTable[i] = copyTable(v) end return newTable end local classMt = {} function classMt:__newindex(key, value) self.vals[key] = value end function classMt:__index(key) error("Trying to index a class") end function classMt:__call(...) local instance = setmetatable(copyTable(self.props), {__index = self.vals}) self.vals[self.name](instance, ...) return instance end function classMt:__tostring() return ('<class "%s">'):format(self.name) end local function createClass(name, vals) local props = vals[1] or {} vals[1] = nil return setmetatable({name = name, vals = vals, props = props}, classMt) end class = function(name) return function(v) _ENV[name] = createClass(name, v) end end end -- -- Sample -- class("Vector2") { { x = 0; y = 0; }; } function Vector2:Vector2(x, y) self.x, self.y = x, y end local PlayerPosition = Vector2(30, 30) print(PlayerPosition.x)
run
|
edit
|
history
|
help
0
True every 5
PAID HACK PuBG
Lua stuff
Fixed
finding volume of pyramids (for me, but feel free to use)
ROBLOX Ui Play Button
Visala Test
test
10 Line challenge
Personal Use (Among Us)