Module:Equipment

local Equipment = {}

local equipments = {}

local EquipmentData = require('Module:EquipmentData')

function Equipment:get(stat, name) return self:create(name)[stat] end

function Equipment:create(name) if name == nil then return EquipmentData --check if we already have it	elseif equipments[name] then return equipments[name] else --Catch a failed require local success, equipment_table = pcall(function return require(mw.ustring.format('Module:%s', name)) end) --require failed if not success then --create a EquipmentData with what we have equipment_table = {_name = name} end local equipment = EquipmentData(equipment_table) equipments[name] = equipment return equipment end end

function Equipment:get_module(name) if name == nil then return nil end return mw.ustring.format('Module:%s', name) end

function Equipment:extend(data) data = data or {} setmetatable(data, data) data.__index = self data.__call = self.__call return data end

Equipment.__call = Equipment.create setmetatable(Equipment, Equipment)

return Equipment