Module:ItemsByStat: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 24: Line 24:
p.tablefy = function(frame)
p.tablefy = function(frame)
local stat = frame.args[1]
local stat = frame.args[1]
local tabledata = selectByStat(stat)
local tableData = selectByStat(stat)
Item = tabledata[1]
local outString = ""
Value = tabledata[3]
return tableData[1][1]
output = ""
-- for i=1,#Item do
for i=1,#Item do
-- outString = outString.."Name: [["..Item[i].."]] Increased Weapon Damage: "..Value[i].."\n\n"
output = output.."Name: [["..Item[i].."]] Increased Weapon Damage: "..Value[i].."\n\n"
-- end
end
-- return outString
return output
end
end


return p
return p

Revision as of 14:33, 27 September 2024

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

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

local selectByStat = function(stat)
	local Name,Tier,Value = {},{},{}
	local outData = {Name,Tier,Value}
	local inKeys = {"Name","Tier",stat};
	local i = 1
	
	for m,itemData in pairs(AllItemData) do
		for itemFieldName,n in pairs(itemData) do
			if itemFieldName == stat then 
				for x = 1,3 do
					outData[x][i] = itemData[inKeys[x]]
					i = i+1;
					break
				end
			end
		end
	end
	return outData
end

p.tablefy = function(frame)
	local stat = frame.args[1]
	local tableData = selectByStat(stat)
	local outString = ""
	return tableData[1][1]
--	for i=1,#Item do
--		outString = outString.."Name: [["..Item[i].."]]	Increased Weapon Damage: "..Value[i].."\n\n"
--	end
--	return outString
end

return p