Module:ItemSources: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 23: Line 23:
:addClass('wikitable')
:addClass('wikitable')
:tag('tr')
:tag('tr')
:tag('th')
:tag('th'):wikitext('Source'):done()
:wikitext('Source')
:tag('th'):wikitext('Level'):done()
:done()
:tag('th'):wikitext('Quantity'):done()
:tag('th')
:tag('th'):wikitext('Frequency'):done()
:wikitext('Level')
:done()
:tag('th')
:wikitext('Quantity')
:done()
:tag('th')
:wikitext('Frequency')
:done()
:done()
:done()
for _, source in ipairs(smwdata) do
mw.logObject(source)
out:tag('tr')
:tag('td'):wikitext(source.source):done()
:tag('td'):wikitext():done()
:tag('td'):wikitext(source.quantity):done()
:tag('td'):wikitext(source.rarity):done()
:done()
end
return out
return out

Revision as of 13:30, 28 November 2024

Module documentation
This documentation is transcluded from Module:ItemSources/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:ItemSources/doc. [edit]
Module:ItemSources's function main is invoked by Template:ItemSources.
Module:ItemSources requires Module:Param Parse.
Module:ItemSources requires Module:Profession clickpic.

local p = {}
local hc = require('Module:Param Parse').has_content
local pcp = require('Module:Profession clickpic')._main

function p.main(frame)
	local args = frame:getParent().args
	return p._main(args)
end

function p._main(args)
	local item = args[1] or mw.title.getCurrentTitle().fullText
	
	local q = {
		'[[Dropped item::' .. item .. ']]',
		'?Dropped from=source',
		'?Dropped quantity=quantity',
		'?Rarity=rarity'
	}
	local smwdata = mw.smw.ask(q)
	mw.logObject(smwdata)
	
	local out = mw.html.create('table')
		:addClass('wikitable')
		:tag('tr')
			:tag('th'):wikitext('Source'):done()
			:tag('th'):wikitext('Level'):done()
			:tag('th'):wikitext('Quantity'):done()
			:tag('th'):wikitext('Frequency'):done()
		:done()
		
	for _, source in ipairs(smwdata) do
		mw.logObject(source)
		out:tag('tr')
			:tag('td'):wikitext(source.source):done()
			:tag('td'):wikitext():done()
			:tag('td'):wikitext(source.quantity):done()
			:tag('td'):wikitext(source.rarity):done()
		:done()
	end
	
	return out
end

return p