Module:ItemTables: Difference between revisionsGive feedback
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, | 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 = { | ||
itemName["Name"] | |||
} | } | ||
} | } | ||
if( | if(itemName[property] ~= nil and itemName["Name"] ~= nil) then | ||
listofItems = listofItems .. | 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( | :tag('td'):wikitext(get_cost(itemName["Name"])):done() | ||
:tag('td'):wikitext(get_type( | :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, | -- 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 | ||