Module:ItemTables: Difference between revisions

Jump to navigation Jump to search
add link patterns,
cleanup unused code, start building table
Line 95: Line 95:
return desc
return desc
end
end


p.itemPropTable = function(frame)
p.itemPropTable = function(frame)
local TableValues = {}
local TableValues = {}
local requirements = {}
local listofItems = ""
local listofItems = ""
local property = frame.args[1] or mw.title.getCurrentTitle().text
local property = frame.args[1] or mw.title.getCurrentTitle().text
Line 104: Line 104:
-- local item = get_json_item(item_name)
-- local item = get_json_item(item_name)
-- if(item == nil) then return "Item Not Found what" end
-- if(item == nil) then return "Item Not Found what" end
local createTable = mw.html.create('table')
:addClass('wikitable sortable')
local createTableRow = mw.html.create('tr')
createTableRow
:tag('th'):wikitext('Name'):done()
:tag('th'):wikitext('Cost'):done()
createTable:node(createTableRow)
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, statName in pairs(data) do --statName is the key. go through whole table. in this case itemName can be upgrade_improved_stamina
if(statName[property] ~= nil and statName["Name"] ~= nil) then
if(statName[property] ~= nil and statName["Name"] ~= nil) then
listofItems = listofItems .. statName["Name"] .. "<br/>"
listofItems = listofItems .. statName["Name"] .. "<br/>"
local tableData = mw.html.create('tr')
tableData
:tag('td'):wikitext(statName["Name"]):done()
:tag('td'):wikitext(statName["Cost"]):done()
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, statName["Name"]) -- i may want to make a table first, so it includes weapon and cost to make it sortable.
end
end
end
end
return listofItems
for _, row in ipairs(requirements) do
createTableRow:node(row)
end
--createTable:node(createTableRow)
return tostring(createTable), listofItems
--return listofItems --temp replace with line above
--return table.concat(TableValues, ", ")
--return table.concat(TableValues, ", ")
--for i,v in pairs(data) do
 
-- if(type(item[property]) == "table") then
-- for i,v in pairs(item[property]) do
-- if(v == property) then
-- TableValues = table.insert(TableValues, item["Name"])
-- end
-- end
-- return table.concat(TableValues, ", ")
-- end
--end
--return item[property]
--return tableValues[property]
end
end


return p
return p