Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:GasIcon: Difference between revisions

From Stationeers Community Wiki
RA2lover (talk | contribs)
m remove duplicate quotes from inline css
RA2lover (talk | contribs)
replace old template invoke function
 
(14 intermediate revisions by the same user not shown)
Line 2: Line 2:
local Gas = require("Module:Gas")
local Gas = require("Module:Gas")
local p = {}
local p = {}
     function p.GetIcon(frame)
     local function CreateStyle(args)
        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={}
         local size = args.Size or "32px"
        css.display = "inline-block"
         return [["height: ]]..size.."; width: auto; vertical-align: middle;"..[["]]
         css.height = args.Size or "32px"
         css.width = css.height
        css["vertical-align"] = "baseline"
       
        return css
     end
     end


     function p.GetIcon2(frame)
     function p.GetIcon(frame)
         local args = frame:getParent().args
         local args = frame:getParent().args
         local gas = Gas.GetGas(args[1])
         local gas = Gas.GetGas(args[1])
         mw.logObject(args)
         mw.logObject(args)
         return [[<a href="]]..gas.HumanReadableName..[[">]]
         local html = mw.html.create("span")
            ..[[<img src="]]..gas.Image..[[" style=]]..CreateStyle(args)..[[/>]]
                    :css(CreateStyle(args))
            ..[[</a>]]
                    :wikitext("[["..gas.Image.."|link="..gas.HumanReadableName.."]]")
                :done()
        return html
     end
     end
    p.GetIcon2 = p.GetIcon --still kept for sandbox template
return p
return p

Latest revision as of 06:51, 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 = {}
    local function CreateStyle(args)

        local css={}
        css.display = "inline-block"
        css.height = args.Size or "32px"
        css.width = css.height
        css["vertical-align"] = "baseline"
        
        return css
    end

    function p.GetIcon(frame)
        local args = frame:getParent().args
        local gas = Gas.GetGas(args[1])
        mw.logObject(args)
        local html = mw.html.create("span")
                    :css(CreateStyle(args))
                    :wikitext("[["..gas.Image.."|link="..gas.HumanReadableName.."]]")
                :done()
        return html
    end
    p.GetIcon2 = p.GetIcon --still kept for sandbox template

return p