Changes

Undo revision 342923 by Ckwng (talk) On second thought, not needed
Line 1: Line 1: −
local BaseData = require('Module:BaseData')
+
local Ship = {}
 +
local ships = {}
   −
local Ship = BaseData{
+
local ShipData
_ships = {},
  −
_data_class = false,
  −
}
      
function Ship:_prepareShipData()
 
function Ship:_prepareShipData()
self._data_class = self._data_class or require('Module:ShipData')
+
ShipData = ShipData or require('Module:ShipData')
 
end
 
end
   Line 17: Line 15:  
self:_prepareShipData()
 
self:_prepareShipData()
 
if name == nil then
 
if name == nil then
return self._data_class()
+
return ShipData()
 
end
 
end
 
if model == nil then
 
if model == nil then
Line 26: Line 24:  
end
 
end
 
--check if we already have it
 
--check if we already have it
if self._ships[name] and self._ships[name][model] then
+
if ships[name] and ships[name][model] then
return self._ships[name][model]
+
return ships[name][model]
 
else
 
else
local ship = self._data_class(self:get_table(name, model))
+
local ship = ShipData(self:get_table(name, model))
if not self._ships[name] then
+
if not ships[name] then
self._ships[name] = {}
+
ships[name] = {}
 
end
 
end
self._ships[name][model] = ship
+
ships[name][model] = ship
 
return ship
 
return ship
 
end
 
end
Line 93: Line 91:  
end
 
end
 
return mw.ustring.format('Module:%s', name)
 
return mw.ustring.format('Module:%s', name)
end
  −
  −
function Ship:extend(data)
  −
data = data or {}
  −
setmetatable(data, data)
  −
data.__index = self
  −
data.__call = self.__call
  −
return data
   
end
 
end
  
Anonymous user