commit c0c37059d6a37a425b7190607c9920781d191c2c Author: lordlogo2002 Date: Thu Jan 1 16:50:43 2026 +0100 init diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..f7cf62e --- /dev/null +++ b/main.lua @@ -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 diff --git a/oop/oop.lua b/oop/oop.lua new file mode 100644 index 0000000..120695e --- /dev/null +++ b/oop/oop.lua @@ -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 +]] + diff --git a/oop/utils.lua b/oop/utils.lua new file mode 100644 index 0000000..6a161e4 --- /dev/null +++ b/oop/utils.lua @@ -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 +}