Compare commits

...

2 Commits

Author SHA1 Message Date
mars 2297013f37 Add classic.lua 2023-04-10 23:42:14 -04:00
mars 0d4a94ced5 Move CREDITS.txt to root 2023-04-10 23:40:07 -04:00
3 changed files with 70 additions and 1 deletions

2
CREDITS.txt Normal file
View File

@ -0,0 +1,2 @@
- `assets/small-blocky-font.png` is licensed under CC-BY 3.0 and was created by Jerom (source: https://opengameart.org/content/small-blocky-font)
- `classic.lua` is licensed under the MIT license and was created by rxi (source: https://raw.githubusercontent.com/rxi/classic/master/classic.lua)

View File

@ -1 +0,0 @@
- `small-blocky-font.png` is licensed under CC-BY 3.0 and was created by Jerom (source: https://opengameart.org/content/small-blocky-font)

68
classic.lua Normal file
View File

@ -0,0 +1,68 @@
--
-- classic
--
-- Copyright (c) 2014, rxi
--
-- This module is free software; you can redistribute it and/or modify it under
-- the terms of the MIT license. See LICENSE for details.
--
local Object = {}
Object.__index = Object
function Object:new()
end
function Object:extend()
local cls = {}
for k, v in pairs(self) do
if k:find("__") == 1 then
cls[k] = v
end
end
cls.__index = cls
cls.super = self
setmetatable(cls, self)
return cls
end
function Object:implement(...)
for _, cls in pairs({...}) do
for k, v in pairs(cls) do
if self[k] == nil and type(v) == "function" then
self[k] = v
end
end
end
end
function Object:is(T)
local mt = getmetatable(self)
while mt do
if mt == T then
return true
end
mt = getmetatable(mt)
end
return false
end
function Object:__tostring()
return "Object"
end
function Object:__call(...)
local obj = setmetatable({}, self)
obj:new(...)
return obj
end
return Object