rename folder src to concord

This commit is contained in:
Tjakka5 2020-01-04 10:50:13 +01:00
parent 451b88cdea
commit f502f1b9f6
14 changed files with 0 additions and 0 deletions

33
concord/worlds.lua Normal file
View file

@ -0,0 +1,33 @@
--- Worlds
-- Container for registered Worlds
local PATH = (...):gsub('%.[^%.]+$', '')
local Type = require(PATH..".type")
local Worlds = {}
--- Registers a World.
-- @param name Name to register under
-- @param world World to register
function Worlds.register(name, world)
if (type(name) ~= "string") then
error("bad argument #1 to 'Worlds.register' (string expected, got "..type(name)..")", 3)
end
if (not Type.isWorld(world)) then
error("bad argument #2 to 'Worlds.register' (world expected, got "..type(world)..")", 3)
end
if (rawget(Worlds, name)) then
error("bad argument #2 to 'Worlds.register' (World with name '"..name.."' is already registerd)", 3)
end
Worlds[name] = world
end
return setmetatable(Worlds, {
__index = function(_, name)
error("Attempt to index world '"..tostring(name).."' that does not exist / was not registered", 2)
end
})