Changes
Add some sort of memoization
local Ship = {}
local Ship = {}
local ships = {}
local ShipData = require('Module:ShipData')
local ShipData = require('Module:ShipData')
function Ship:create(name, model)
function Ship:create(name, model)
local ship_table = require(mw.ustring.format('Module:%s', name))
if ships[name] and ships[name][model] then
return ships[name][model]
else
local ship_table = require(mw.ustring.format('Module:%s', name))
local ship = ShipData:create(ship_table[model])
if not ships[name] then
ships[name] = {}
end
ships[name][model] = ship
return ship
end
end
end