Module:StationInfobox: Difference between revisions
Appearance
Content deleted Content added
Created page with "local Infobox = {} local HF = require('Module:HF') local stations = mw.loadData( 'Module:FooBar/stations' ) function Infobox.Quantify( field, vars ) local unit = field.U..." |
mNo edit summary |
||
| (25 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
local HF = require('Module:HF') |
local HF = require('Module:HF') |
||
local |
local lang = mw.language.new('en') |
||
local stations = { |
|||
["orbis"] = "[[File:Orbis_station_newsletter.jpg|306px]]", |
|||
["ocellus"] = "[[File:OcellusStation_001.jpg|306px]]", |
|||
["coriolis"] = "[[File:CoriolisStation_001.jpg|306px]]", |
|||
["outpost"] = "[[File:Outpost_001.jpg|306px]]", |
|||
} |
|||
function Infobox.Quantify( field, vars ) |
function Infobox.Quantify( field, vars ) |
||
| Line 16: | Line 23: | ||
function Infobox.MainImage( field, vars ) |
function Infobox.MainImage( field, vars ) |
||
local output = '' |
local output = '' |
||
local station = field.Station |
local station = field.Station:lower() |
||
| ⚫ | |||
local image = field.Image or '' |
|||
| ⚫ | |||
return output |
|||
if HF.isempty(image) then |
|||
| ⚫ | |||
| ⚫ | |||
else |
|||
output = "[[File:Placeholder.png|306px]]" |
|||
end |
|||
else |
|||
| ⚫ | |||
end |
end |
||
| ⚫ | |||
return output |
return output |
||
end |
end |
||
Latest revision as of 22:27, 11 July 2015
Documentation for this module may be created at Module:StationInfobox/doc
local Infobox = {}
local HF = require('Module:HF')
local lang = mw.language.new('en')
local stations = {
["orbis"] = "[[File:Orbis_station_newsletter.jpg|306px]]",
["ocellus"] = "[[File:OcellusStation_001.jpg|306px]]",
["coriolis"] = "[[File:CoriolisStation_001.jpg|306px]]",
["outpost"] = "[[File:Outpost_001.jpg|306px]]",
}
function Infobox.Quantify( field, vars )
local unit = field.Unit or ''
local value = field.Value or field.Default or '?'
if HF.isempty(value) then
return '---'
else
return value .. ' ' .. unit
end
end
function Infobox.MainImage( field, vars )
local output = ''
local station = field.Station:lower()
local image = field.Image or ''
if HF.isempty(image) then
if not HF.isempty(station) and stations[station] ~= nil then
output = stations[station]
else
output = "[[File:Placeholder.png|306px]]"
end
else
output = "[[File:" .. image .. "|306px]]"
end
return output
end
return Infobox