local log = nrequire("log.lua") local fun = nrequire("fn.lua") local a = {} local arcs = {} local arc_required_fields = { "Name", "Init", "Serialize", "DeSerialize" } function a.RegisterArc(tbl) for k,v in pairs(arc_required_fields) do assert(tbl[v],"Attempted to register an arc, which didn't have a required field:" .. v) end if arcs[tbl.Name] ~= nil then log.warn("Attempted to register and arc named " .. tbl.Name .. " when another arc by that name already exists. Overwriteing...") end arcs[tbl.Name] = tbl log.debug("Registered new arc type:" .. tbl.Name) end local function MakeArcBase(name) log.debug("Making arc:" .. name) assert(arcs[name] ~= nil, "Attempted to make an unknown arc type:\"" .. name .. "\". Known arc types are:" .. table.concat(table.GetKeys(arcs),"\n\t")) local arc_m = { __index = arcs[name] } arcbase = {} setmetatable(arcbase,arc_m) return arcbase end function a.MakeArc(name, ...) local arc = MakeArcBase(name) arc:Init(...) return arc end function a.MakeArcWithData(name,data) local arc = MakeArcBase(name) arc:DeSerialize(data) return arc end concommand.Add("artery_printquestarcs",function(ply,cmd,args) PrintTable(arcs) end) return a