Difference between revisions of "Module:EquipmentPage"
(Created page with "local Utils = require("Module:Utils") local Equipment = require('Module:Equipment') return { buildable = function(frame) local args = Utils.getTemplateArgs(frame)...") |
(Template:Equipment en text now uses & prioritises _info_en from modules for en text.) |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | local | + | local _ = require("Module:Core") |
local Equipment = require('Module:Equipment') | local Equipment = require('Module:Equipment') | ||
| + | |||
| + | function getEquipment(frame) | ||
| + | local args = _.getTemplateArgs(frame) | ||
| + | local name = args.explicit[1] or args.implicit.pagename or "" | ||
| + | return Equipment(name) | ||
| + | end | ||
| + | |||
| + | function wikipediaLink(wikipedia) | ||
| + | if not wikipedia then | ||
| + | return | ||
| + | end | ||
| + | local parts = _.split(wikipedia, ":") | ||
| + | if parts[1] and parts[2] then | ||
| + | return string.format("[[wikipedia:%s:%s|%s]]", parts[1], parts[2], parts[2]) | ||
| + | else | ||
| + | return string.format("[[wikipedia:%s|%s]]", wikipedia, wikipedia) | ||
| + | end | ||
| + | end | ||
return { | return { | ||
| + | info = function(frame) | ||
| + | return getEquipment(frame):info() | ||
| + | end, | ||
| + | info_en = function(frame) | ||
| + | return getEquipment(frame):info_en() | ||
| + | end, | ||
| + | wikipedia = function(frame) | ||
| + | return wikipediaLink(getEquipment(frame):wikipedia()) | ||
| + | end, | ||
buildable = function(frame) | buildable = function(frame) | ||
| − | + | return getEquipment(frame):buildable() and "true" or "" | |
| − | + | end, | |
| − | + | improvable = function(frame) | |
| − | return | + | return getEquipment(frame):improvable() and "true" or "" |
end, | end, | ||
} | } | ||
Latest revision as of 16:28, 8 May 2024
Documentation for this module may be created at Module:EquipmentPage/doc
local _ = require("Module:Core")
local Equipment = require('Module:Equipment')
function getEquipment(frame)
local args = _.getTemplateArgs(frame)
local name = args.explicit[1] or args.implicit.pagename or ""
return Equipment(name)
end
function wikipediaLink(wikipedia)
if not wikipedia then
return
end
local parts = _.split(wikipedia, ":")
if parts[1] and parts[2] then
return string.format("[[wikipedia:%s:%s|%s]]", parts[1], parts[2], parts[2])
else
return string.format("[[wikipedia:%s|%s]]", wikipedia, wikipedia)
end
end
return {
info = function(frame)
return getEquipment(frame):info()
end,
info_en = function(frame)
return getEquipment(frame):info_en()
end,
wikipedia = function(frame)
return wikipediaLink(getEquipment(frame):wikipedia())
end,
buildable = function(frame)
return getEquipment(frame):buildable() and "true" or ""
end,
improvable = function(frame)
return getEquipment(frame):improvable() and "true" or ""
end,
}