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

Module:ItemGrid: Difference between revisions

From ARC Raiders Wiki
Content deleted Content added
Dread (talk | contribs)
v0.1 -created a module for Traders' buyable items
 
Dread (talk | contribs)
changed rarityColors opacity
Line 3: Line 3:
-- Rarity border colors
-- Rarity border colors
local rarityColors = {
local rarityColors = {
Common = "#717471",
Common = "#717471cc",
Uncommon = "#41eb6a",
Uncommon = "#41eb6acc",
Rare = "#1ecbfc",
Rare = "#1ecbfccc",
Epic = "#d8299b",
Epic = "#d8299bcc",
Legendary = "#fbc700",
Legendary = "#fbc700cc",
}
}



Revision as of 12:57, 27 October 2025

Documentation for this module may be created at Module:ItemGrid/doc

local p = {}

-- Rarity border colors
local rarityColors = {
    Common = "#717471cc",     
    Uncommon = "#41eb6acc",   
    Rare = "#1ecbfccc",       
    Epic = "#d8299bcc",       
    Legendary = "#fbc700cc",  
}

function p.render(frame)
    local args = frame:getParent().args
    local html = mw.html.create("div"):addClass("item-grid")

	local i = 1
    while args["image" .. i] and i < 100 do
        local isLimited = args["isLimited" .. i] or false
        local rarity = args["rarity" .. i] or ""
        local border = rarityColors[rarity] or rarityColors["Common"]

        local item = html:tag("div")
            :addClass("item-cell")
            :css("border", "1px solid " .. border)
        
        if (isLimited == ("true" or "True")) then 
        item:tag("div")
        	:addClass("Icon_TimeReset")
        	:wikitext("[[File:Icon_TimeReset.png|16px]]")
        	:css("position", "absolute")
        	:css("left", "calc(100% - 20px)")
        	:css("top", "0%")
        end
        
        if rarity ~= "" then   --reformat this repetitive block if you can
        item:tag("div")
            :addClass("item-image")
            :wikitext(string.format("%s", args["image" .. i]))
        	:tag("div")
        		:addClass(string.format("curve-%s", rarity))
				:done()
		else
			item:tag("div")
            :addClass("item-image")
            :wikitext(string.format("%s", args["image" .. i]))
        end
	
		item:tag("div")
	    	    :addClass("item-name")
	    	    :wikitext(args["name" .. i] or "")
	    
        item:tag("div")
            :addClass("data-table")
        
        	:tag("div")
	    	    :addClass("category-icon")
	    	    :wikitext(args["category-icon" .. i] or "")
	    	    :done()
        	    
        	:tag("div")
        	    :addClass("item-price")
        	    :wikitext(args["price" .. i] or "")
        	    :done()
		i = i + 1
    end

    return tostring(html)
end

return p