Module:ItemsByStat: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Created page with "local p = {}; local data = mw.loadJsonData("Data:ItemData.json") p.select = function(frame) local stat = frame.args[1] 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 return p"
 
No edit summary
Line 1: Line 1:
local p = {};
local p = {}
local data = mw.loadJsonData("Data:ItemData.json")
local data = mw.loadJsonData("Data:ItemData.json")



Revision as of 06:56, 27 September 2024

Documentation for this module may be created at Module:ItemsByStat/doc

local p = {}
local data = mw.loadJsonData("Data:ItemData.json")

p.select = function(frame)
	local stat = frame.args[1]
	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

return p