Module:ItemsByStat: Difference between revisions
Jump to navigation
Jump to search
SerpentofSet (talk | contribs) No edit summary |
SerpentofSet (talk | contribs) No edit summary |
||
Line 23: | Line 23: | ||
local stat = frame.args[1] | local stat = frame.args[1] | ||
local tabledata = selectByStat(stat) | local tabledata = selectByStat(stat) | ||
Item = tabledata[1] | |||
Value = tabledata[2] | |||
output = "" | output = "" | ||
for i, | for i=1,#Item do | ||
output = output.."Name: ".. | output = output.."Name: "..Item[i].." Value: "..Value[i].."\n" | ||
end | end | ||
return output | return output |
Revision as of 07:23, 27 September 2024
Documentation for this module may be created at Module:ItemsByStat/doc
local p = {}
local data = mw.loadJsonData("Data:ItemData.json")
local selectByStat = function(stat)
local Item,Value = {},{}
local i = 1
for m,v in pairs(data) do
for n,w in pairs(v) do
if n == stat then
Item[i] = v["Name"]
Value[i] = v[stat]
i = i+1
break
end
end
end
local b = {Item, Value}
return b
end
p.tablefy = function(frame)
local stat = frame.args[1]
local tabledata = selectByStat(stat)
Item = tabledata[1]
Value = tabledata[2]
output = ""
for i=1,#Item do
output = output.."Name: "..Item[i].." Value: "..Value[i].."\n"
end
return output
end
return p