diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-03 19:37:28 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-02-03 19:51:07 +0000 |
commit | 1ebd7d9b7b62c8e05d527611a1944ed1a876b890 (patch) | |
tree | cfc5ddf3fc15985c4369aa12d56de5fa8d6fc7e5 /common/class.lua | |
parent | ec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 (diff) |
debug drawing change, zoom clamping, partial refactoring of class mechanisms to allow inheritance, minor refactor of noise generator, changes to temp worldgen, rework of class constructor mechanism
Diffstat (limited to 'common/class.lua')
-rw-r--r-- | common/class.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/class.lua b/common/class.lua new file mode 100644 index 0000000..37cf7bd --- /dev/null +++ b/common/class.lua @@ -0,0 +1,23 @@ +local function class() + local T = {} + T.__index = T + return T +end + +local function extend(Base) + local T = {} + T.__index = T + for k,v in pairs(Base) do + if k:sub(1,2) == "__" and k~="__index" then + T[k]=v + end + end + setmetatable(T,{__index=Base}) +end + +return setmetatable({ + class=class, + extend=extend +},{__call=class}) + + |