• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "Module:Ship"

From Kancolle Wiki
Jump to navigation Jump to search
com>Ckwng
com>Ckwng
(Add module page title retrieval)
Line 26: Line 26:
 
return ship
 
return ship
 
end
 
end
 +
end
 +
 +
function Ship:get_module(name)
 +
if name == nil then
 +
return nil
 +
end
 +
return mw.ustring.format('Module:%s', name)
 
end
 
end
  

Revision as of 22:31, 28 February 2015

Documentation for this module may be created at Module:Ship/doc

local Ship = {}
local ships = {}

local ShipData = require('Module:ShipData')

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

function Ship:create(name, model)
	if name == nil then
		return ShipData()
	end
	if model == nil then
		model = ""
	end
	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(ship_table[model])
		if not ships[name] then
			ships[name] = {}
		end
		ships[name][model] = ship
		return ship
	end
end

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

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

return Ship