Module:Usedin: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) mNo edit summary |
Kiokurashi (talk | contribs) mNo edit summary |
||
Line 4: | Line 4: | ||
local tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" style="color: #b847cb;" data-simple-tooltip="%s">%s</span>]] | local tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" style="color: #b847cb;" data-simple-tooltip="%s">%s</span>]] | ||
local rowstruct = [=[<tr> | local rowstruct = [=[<tr> | ||
<td>[[File:%s. | <td>[[File:%s.%s|40px|link=]] [[%s]]</td> | ||
<td>%s</td> | <td>%s</td> | ||
<td>%s</td> | <td>%s</td> | ||
Line 36: | Line 36: | ||
local quantity = (results[r].Resource1 == item and quantity1) or (results[r].Resource2 == item and quantity2) or (results[r].Resource3 == item and quantity3) or (results[r].Resource4 == item and quantity4) | local quantity = (results[r].Resource1 == item and quantity1) or (results[r].Resource2 == item and quantity2) or (results[r].Resource3 == item and quantity3) or (results[r].Resource4 == item and quantity4) | ||
-- Build string and add to return table | -- Build string and add to return table | ||
ret[#ret+1] = string.format(rowstruct, results[r]._pageName, results[r]._pageName, | ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "png", results[r]._pageName, | ||
string.format(tooltipstruct, NumberFormater.formatnumber(quantity), NumberFormater.formatwithseperator(quantity), "Smithing") ) | string.format(tooltipstruct, NumberFormater.formatnumber(quantity), NumberFormater.formatwithseperator(quantity), "Smithing") ) | ||
end | end | ||
Line 52: | Line 52: | ||
if #results > 0 then | if #results > 0 then | ||
for r = 1, #results do | for r = 1, #results do | ||
ret[#ret+1] = string.format(rowstruct, results[r]._pageName, results[r]._pageName, | ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "png", results[r]._pageName, | ||
"Lots", "Stamps" .. string.format(tooltipstruct, results[4].Bonus, "More Info.")) | "Lots", "Stamps" .. string.format(tooltipstruct, results[4].Bonus, "More Info.")) | ||
end | end | ||
Line 68: | Line 68: | ||
if #results > 0 then | if #results > 0 then | ||
for r = 1, #results do | for r = 1, #results do | ||
ret[#ret+1] = string.format(rowstruct, results[r].Icon, results[r].Source, results[r].Amount, results[r].Type) | ret[#ret+1] = string.format(rowstruct, results[r].Icon, "png", results[r].Source, results[r].Amount, results[r].Type) | ||
end | end | ||
end | end | ||
Line 74: | Line 74: | ||
-- <tr><td>{{#if:{{{Icon|}}}|[[File:{{{Icon}}}.gif|40px|link=]] }}{{{Name}}}</td><td>{{NumberNabber|{{{Quantity}}}|{{PAGENAME}}}}</td><td>{{{Source}}}</td></tr> | -- <tr><td>{{#if:{{{Icon|}}}|[[File:{{{Icon}}}.gif|40px|link=]] }}{{{Name}}}</td><td>{{NumberNabber|{{{Quantity}}}|{{PAGENAME}}}}</td><td>{{{Source}}}</td></tr> | ||
local function QueryQuests(item) | local function QueryQuests(item) | ||
local tables = 'Quests' | local tables = 'Quests' | ||
Line 88: | Line 87: | ||
for r = 1, #results do | for r = 1, #results do | ||
local args = {searchText = item, list = results[r].Requirements} | local args = {searchText = item, list = results[r].Requirements} | ||
ret[#ret+1] = string.format( | ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "gif", | ||
string.format(' | string.format('%s#%s|%s', results[r]._pageName, results[r].QuestName, results[r].QuestName), nabber.numberNabber(args), "Quests") | ||
end | end | ||
end | end |
Revision as of 20:00, 14 March 2024
Documentation for this module may be created at Module:Usedin/doc
local p = {}
local cargo = mw.ext.cargo
local NumberFormater = require('Module:NumberFormater')
local tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" style="color: #b847cb;" data-simple-tooltip="%s">%s</span>]]
local rowstruct = [=[<tr>
<td>[[File:%s.%s|40px|link=]] [[%s]]</td>
<td>%s</td>
<td>%s</td>
</tr>]=]
local ret = {}
function p.main(frame)
local item = frame.args[1]
-- QuerySmithingRecipes(item)
-- QueryStamps(item)
-- QueryExtraData(item)
QueryQuests(item)
return table.concat(ret)
end
local function QuerySmithingRecipes(item)
local tables = 'AnvilCraft'
-- Multi-column dependent quantities so query them all.
local fields = '_pageName, Resource1, Resource2, Resource3, Resource4, Quantity1, Quantity2, Quantity3, Quantity4'
local args = {
where = 'AnvilCraft.Resource1="'.. item ..'" OR ' .. 'AnvilCraft.Resource2="'.. item ..'" OR ' .. 'AnvilCraft.Resource3="'.. item ..'" OR ' .. 'AnvilCraft.Resource4="'.. item ..'"',
orderBy = 'AnvilCraft.Item'
}
local results = cargo.query( tables, fields, args )
-- if there are any results.
if #results > 0 then
for r = 1, #results do
-- Set specific quantity
local quantity = (results[r].Resource1 == item and quantity1) or (results[r].Resource2 == item and quantity2) or (results[r].Resource3 == item and quantity3) or (results[r].Resource4 == item and quantity4)
-- Build string and add to return table
ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "png", results[r]._pageName,
string.format(tooltipstruct, NumberFormater.formatnumber(quantity), NumberFormater.formatwithseperator(quantity), "Smithing") )
end
end
end
local function QueryStamps(item)
local tables = 'Stamps'
local fields = '_pageName, Bonus'
local args = {
where = 'Stamps.Material="'.. item,
orderBy = 'Stamps._pageName'
}
local results = cargo.query( tables, fields, args )
if #results > 0 then
for r = 1, #results do
ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "png", results[r]._pageName,
"Lots", "Stamps" .. string.format(tooltipstruct, results[4].Bonus, "More Info."))
end
end
end
local function QueryExtraData(item)
local tables = 'UsedinExtraData'
local fields = 'Icon, Source, Amount, Type'
local args = {
where = 'UsedinExtraData.Item="'.. item,
orderBy = 'UsedinExtraData.Source'
}
local results = cargo.query( tables, fields, args )
if #results > 0 then
for r = 1, #results do
ret[#ret+1] = string.format(rowstruct, results[r].Icon, "png", results[r].Source, results[r].Amount, results[r].Type)
end
end
end
-- <tr><td>{{#if:{{{Icon|}}}|[[File:{{{Icon}}}.gif|40px|link=]] }}{{{Name}}}</td><td>{{NumberNabber|{{{Quantity}}}|{{PAGENAME}}}}</td><td>{{{Source}}}</td></tr>
local function QueryQuests(item)
local tables = 'Quests'
local fields = '_pageName, QuestName, Requirements'
local temp = ''
local args = {
where = 'Quests.Requirements LIKE "%>'.. item ..'<%"',
groupBy = 'Quests._pageName',
}
local results = cargo.query( tables, fields, args )
if #results > 0 then
local nabber = require('Module:Loops') --testing direct call
for r = 1, #results do
local args = {searchText = item, list = results[r].Requirements}
ret[#ret+1] = string.format(rowstruct, results[r]._pageName, "gif",
string.format('%s#%s|%s', results[r]._pageName, results[r].QuestName, results[r].QuestName), nabber.numberNabber(args), "Quests")
end
end
end
function p.main(frame)
local item = frame.args[1]
-- QuerySmithingRecipes(item)
-- QueryStamps(item)
-- QueryExtraData(item)
QueryQuests(item)
return table.concat(ret)
end
return p