Module:GasIcon: Difference between revisions
From Stationeers Community Wiki
More actions
m remove duplicate quotes from inline css |
convert inline html to mw.html |
||
| Line 11: | Line 11: | ||
local function CreateStyle(args) | local function CreateStyle(args) | ||
local | |||
local css={} | |||
css.height = args.Size or "32px" | |||
css.width = "auto" | |||
css["vertical-align"] = "middle" | |||
return css | |||
end | end | ||
| Line 19: | Line 24: | ||
local gas = Gas.GetGas(args[1]) | local gas = Gas.GetGas(args[1]) | ||
mw.logObject(args) | mw.logObject(args) | ||
local html = mw.html.create("a") | |||
:attr("href", gas.Image) | |||
:img() | |||
:attr("src", gas.Image) | |||
:css(CreateStyle(args)) | |||
:alt(gas.HumanReadableName) | |||
:done() | |||
:done() | |||
return html | |||
end | end | ||
return p | return p | ||
Revision as of 05:08, 6 September 2026
Documentation for this module may be created at Module:GasIcon/doc
local GasData = mw.loadData("Module:Gas/data")
local Gas = require("Module:Gas")
local p = {}
function p.GetIcon(frame)
local args = frame:getParent().args
local gas = Gas.GetGas(args[1])
mw.logObject(args)
local size = args.Size or "32px"
return "[["..gas.Image.."|"..size.."|link="..gas.HumanReadableName.."]]"
end
local function CreateStyle(args)
local css={}
css.height = args.Size or "32px"
css.width = "auto"
css["vertical-align"] = "middle"
return css
end
function p.GetIcon2(frame)
local args = frame:getParent().args
local gas = Gas.GetGas(args[1])
mw.logObject(args)
local html = mw.html.create("a")
:attr("href", gas.Image)
:img()
:attr("src", gas.Image)
:css(CreateStyle(args))
:alt(gas.HumanReadableName)
:done()
:done()
return html
end
return p