This commit is contained in:
Chipperfluff 2026-01-01 16:50:43 +01:00
commit c0c37059d6
3 changed files with 36 additions and 0 deletions

12
main.lua Normal file
View File

@ -0,0 +1,12 @@
utils = require("oop/utils")
class = {
name = "MyClass",
sayHello = function(self)
print("Hello from " .. self.name)
end
}
obj = utils.deepcopy(class)
obj.name = "Carl"
obj.sayHello(obj) -- Output: Hello from Carl

9
oop/oop.lua Normal file
View File

@ -0,0 +1,9 @@
--[[
the plan is to create a simple oop system in lua
it might not work liky python
think of it more like a facory system
with at least the concept of self
]]

15
oop/utils.lua Normal file
View File

@ -0,0 +1,15 @@
local function deepcopy(t)
local new = {}
for k, v in pairs(t) do
if type(v) == "table" then
new[k] = deepcopy(v)
else
new[k] = v
end
end
return new
end
return {
deepcopy = deepcopy
}