Difference between revisions of "Module:Items"
From Nookipedia, the Animal Crossing wiki
(testing if this is a problem with this (will redo, if it's not)) Tag: Blanking |
Tag: Undo |
||
Line 1: | Line 1: | ||
− | + | local p = {} | |
+ | function p.outputFurniture (frame) | ||
+ | local game = frame.args[2] | ||
+ | local data = mw.text.jsonDecode(frame.args[1]) | ||
+ | tbl = {} | ||
+ | table.foreach(data, function(k, v) table.insert(tbl, { [k] = v }) end ) | ||
+ | table.sort(tbl, function(k, v) return string.len(table.foreach(k, function(k2, v2) return k2 end)) < string.len(table.foreach(v, function(k2, v2) return k2 end)) end) | ||
+ | local furnitureOutput = "" | ||
+ | table.foreach(tbl, function(k, v) | ||
+ | table.foreach(tbl[k], function(k2, v2) furnitureOutput = furnitureOutput .. frame:expandTemplate{ title = "HouseItem", args = { item = k2, count = v2['count'], img = v2['img'], game = game } } end ) end ) | ||
+ | return furnitureOutput | ||
+ | end | ||
+ | return p |
Revision as of 02:16, June 25, 2020
Documentation for this module may be created at Module:Items/doc
local p = {}
function p.outputFurniture (frame)
local game = frame.args[2]
local data = mw.text.jsonDecode(frame.args[1])
tbl = {}
table.foreach(data, function(k, v) table.insert(tbl, { [k] = v }) end )
table.sort(tbl, function(k, v) return string.len(table.foreach(k, function(k2, v2) return k2 end)) < string.len(table.foreach(v, function(k2, v2) return k2 end)) end)
local furnitureOutput = ""
table.foreach(tbl, function(k, v)
table.foreach(tbl[k], function(k2, v2) furnitureOutput = furnitureOutput .. frame:expandTemplate{ title = "HouseItem", args = { item = k2, count = v2['count'], img = v2['img'], game = game } } end ) end )
return furnitureOutput
end
return p