Difference between revisions of "Module:Drop"

From Curse of Aros
Jump to: navigation, search
 
(17 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
local row = mw.html.create('tr'):addClass('coa-drop-row')
 
local row = mw.html.create('tr'):addClass('coa-drop-row')
 
 
row:tag('td'):wikitext(item:inline(args.Item))
+
row:tag('td'):attr('style', 'text-align:left'):wikitext(item.inline(args.Name))
 
row:tag('td'):wikitext(args.Quantity)
 
row:tag('td'):wikitext(args.Quantity)
row:tag('td'):wikitext(args.Rarity)
+
 +
local text = args.Rate and args.Rate or args.Rarity
 +
 +
local rarity = row:tag('td'):wikitext(text)
 +
if args.Rarity == 'Rare' then
 +
rarity:attr('style', 'background-color: #d7802e; color: #fef0e4')
 +
elseif args.Rarity == 'Uncommon' then
 +
rarity:attr('style', 'background-color: #b99d36; color: #fffefa')
 +
elseif args.Rarity == 'Common' then
 +
rarity:attr('style', 'background-color: #64953b; color: #edffdf')
 +
elseif args.Rarity == 'Very rare' then
 +
rarity:attr('style', 'background-color: #c0291f; color: #fffafa')
 +
end
 
 
 
     return tostring(row)
 
     return tostring(row)

Latest revision as of 10:17, 9 November 2025

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

local export = {}
local item = require('Module:Item')

function export.main(frame)
	local args = frame:getParent().args
	local row = mw.html.create('tr'):addClass('coa-drop-row')
	
	row:tag('td'):attr('style', 'text-align:left'):wikitext(item.inline(args.Name))
	row:tag('td'):wikitext(args.Quantity)
	
	local text = args.Rate and args.Rate or args.Rarity
	
	local rarity = row:tag('td'):wikitext(text)
	if args.Rarity == 'Rare' then
		rarity:attr('style', 'background-color: #d7802e; color: #fef0e4')
	elseif args.Rarity == 'Uncommon' then
		rarity:attr('style', 'background-color: #b99d36; color: #fffefa')
	elseif args.Rarity == 'Common' then
		rarity:attr('style', 'background-color: #64953b; color: #edffdf')
	elseif args.Rarity == 'Very rare' then
		rarity:attr('style', 'background-color: #c0291f; color: #fffafa')
	end
	
    return tostring(row)
end

return export