Documentation The documentation below is transcluded from Module:Test/doc. (edit | history)
A test module to avoid disturbing "real" pages.
See Terraria Wiki:Lua for more information about Lua and links to other help resources.
Feel free to test this module at Terraria Wiki:Sandbox.
local currentFrame
local lang
local data = {
[0] = {
internalName = "Dirt",
tiles = {
"Dirt Block"
}
},
[1] = {
internalName = "Stone",
tiles = {
"Stone Block"
}
},
[2] = {
internalName = "Grass",
tiles = {
"Grass"
}
},
[3] = {
internalName = "Plants",
tiles = {
"Plants"
}
},
[4] = {
internalName = "Torches",
tiles = {
"Torch",
"Blue Torch",
"Red Torch",
"Green Torch",
"Purple Torch",
"White Torch",
"Yellow Torch",
"Demon Torch",
"Cursed Torch",
"Ice Torch",
"Orange Torch",
"Ichor Torch",
"Ultrabright Torch",
"Bone Torch",
"Rainbow Torch",
"Pink Torch",
"Desert Torch",
"Coral Torch",
"Corrupt Torch",
"Crimson Torch",
"Hallowed Torch",
"Jungle Torch"
}
},
[5] = {
internalName = "Trees",
tiles = {
"Tree",
"Corrupt tree",
"Jungle tree",
"Hallow tree",
"Boreal tree",
"Crimson tree",
"Living Mahogany tree",
"Giant Glowing Mushroom"
}
},
[6] = {
internalName = "Iron",
tiles = {
"Iron Ore"
}
},
[7] = {
internalName = "Copper",
tiles = {
"Copper Ore"
}
},
[8] = {
internalName = "Gold",
tiles = {
"Gold Ore"
}
},
[9] = {
internalName = "Silver",
tiles = {
"Silver Ore"
}
}
}
local output = mw.html.create("table"):addClass("terraria lined sortable")
local function printRow(id, data)
for subTileId, tile in ipairs(data["tiles"]) do
local row = output:tag("tr")
if subTileId > 0 then
row:tag("dd")
end
row:tag("td"):wikitext(string.format("%s (%s)", id, subTileId))
row:tag("td")
row:tag("td"):wikitext(tile)
row:tag("td"):wikitext(data["internalName"])
end
end
return {
go = function(frame)
-- init cache
currentFrame = frame
lang = frame.args["lang"] or frame:expandTemplate{ title = "lang" }
-- add header
local header = output:tag("tr")
header:tag("th"):wikitext("Id")
header:tag("th"):wikitext("Image")
header:tag("th"):wikitext("Name")
header:tag("th"):wikitext("Internal Name")
for i = 0, 10 do
printRow(i, data[i])
end
return output
end
}