Module:Aircraft type label

Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules


UsageUsage

{{#invoke:Aircraft type label|label|c172}} gives: Q244479

{{#invoke:Aircraft type label|categoryPrefix|c172}} gives: Cessna 172


Code

local p = {}
local string = require("string");
local aircraftTypes = require("Module:Aircraft type label/data")

p.label = function(frame)
	local code = string.upper(frame.args[1])
	return aircraftTypes[code][1]
end

p.categoryPrefix = function(frame)
	local code = string.upper(frame.args[1])
	local categoryPrefix = aircraftTypes[code][2]

	if categoryPrefix == nil then 
		-- not in the table, return an error message
		return "{{error|Add the type '".. frame.args[1] .. "' in [[Module:Aircraft type label/data]]}}"
	end

	return categoryPrefix
	
end

return p
Category:Modules in pre-alpha development