Module:ItemTables: Difference between revisions

cleanup, remove local functions in favor for main module passing functionality
add new column for quantity of stat increase
Line 2: Line 2:
local data = mw.loadJsonData("Data:ItemData.json")
local data = mw.loadJsonData("Data:ItemData.json")
local get_cost = require("Module:ItemData")._get_cost
local get_cost = require("Module:ItemData")._get_cost
local get_type = require("Module:ItemData")._get_type


-- returns the table of a specific item
-- returns the table of a specific item
Line 102: Line 103:
:tag('th'):wikitext('Cost'):done()
:tag('th'):wikitext('Cost'):done()
:tag('th'):wikitext('Category'):done()
:tag('th'):wikitext('Category'):done()
:tag('th'):wikitext('Stat change'):done()
createTable:node(createTableRow)
createTable:node(createTableRow)


 
-- query all items
for internalName, statName in pairs(data) do --statName is the key. go through whole table. in this case itemName can be upgrade_improved_stamina
for internalName, itemName in pairs(data) do --itemName is the key. go through whole table. in this case itemName can be upgrade_improved_stamina
local display = frame:expandTemplate{
local display = frame:expandTemplate{
title = 'ItemIcon',
title = 'ItemIcon',
args = {
args = {
statName["Name"]
itemName["Name"]
}
}
}
}
if(statName[property] ~= nil and statName["Name"] ~= nil) then
if(itemName[property] ~= nil and itemName["Name"] ~= nil) then
listofItems = listofItems .. statName["Name"] .. "<br/>"
listofItems = listofItems .. itemName["Name"] .. "<br/>"
local tableData = mw.html.create('tr')
local tableData = mw.html.create('tr')
tableData
tableData
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(display):done()
:tag('td'):wikitext(get_cost(statName["Name"])):done()
:tag('td'):wikitext(get_cost(itemName["Name"])):done()
:tag('td'):wikitext(get_type(statName["Name"])):done()
:tag('td'):wikitext(get_type(itemName["Name"])):done()
:tag('td'):wikitext(itemName[property].. " " .. property):done()
table.insert(requirements, tableData)
table.insert(requirements, tableData)
-- TableValues = table.insert(TableValues, statName["Name"]) -- i may want to make a table first, so it includes weapon and cost to make it sortable.
-- TableValues = table.insert(TableValues, itemName["Name"]) -- i may want to make a table first, so it includes weapon and cost to make it sortable.
end
end