Module:Sandbox/Simonlc/Playfield: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 36: | Line 36: | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
local input = frame.args[1] | |||
local rows = mw.text.split(input, '\n' ) | |||
return | |||
local playfield = { | |||
'<table style="line-height: 10px; font-size: 0; border: 1px solid #999">\n<tr><td>' | |||
} | |||
for row=0, #rows do | |||
table.insert(playfield, '<div>') | |||
for cell=0, #row do | |||
table.insert(playfield, '<img src="' .. imgRoot .. tetrisTable[cell:upper()] .. '" alt="">') | |||
end | |||
table.insert(playfield, '</div>') | |||
end | |||
table.insert(playfield, '</td></tr></table>') | |||
return table.join(playfield, '\n') | |||
end | end | ||
return p | return p |
Revision as of 00:56, 22 November 2020
Documentation for this module may be created at Module:Sandbox/Simonlc/Playfield/doc
local imgRoot = "/images/";
local graphicTable = {
[" "] = "1/18/Tet.png", -- Blank
["."] = "1/18/Tet.png",
-- Pieces
["T"] = "2/20/TTet.png",
["I"] = "1/19/ITet.png",
["O"] = "2/20/OTet.png",
["Z"] = "c/c6/ZTet.png",
["S"] = "b/bc/STet.png",
["L"] = "5/51/LTet.png",
["J"] = "8/85/JTet.png",
["G"] = "8/88/GTet.png", -- garbage
-- Line clear effect
["-"] = "3/38/-Tet.png",
["X"] = "0/04/XTet.png",
["B"] = "6/6d/BTet.png",
["C"] = "4/42/CTet.png",
["P"] = "9/9a/PTet.png",
["1"] = "9/9f/1Tet.png",
["2"] = "4/4f/2Tet.png",
["3"] = "0/08/3Tet.png",
["4"] = "0/0d/4Tet.png",
["5"] = "9/93/5Tet.png",
["6"] = "e/e7/6Tet.png",
["7"] = "c/cd/7Tet.png",
["8"] = "e/e6/8Tet.png",
["9"] = "c/c8/9Tet.png",
};
local p = {}
function p.main(frame)
local input = frame.args[1]
local rows = mw.text.split(input, '\n' )
local playfield = {
'<table style="line-height: 10px; font-size: 0; border: 1px solid #999">\n<tr><td>'
}
for row=0, #rows do
table.insert(playfield, '<div>')
for cell=0, #row do
table.insert(playfield, '<img src="' .. imgRoot .. tetrisTable[cell:upper()] .. '" alt="">')
end
table.insert(playfield, '</div>')
end
table.insert(playfield, '</td></tr></table>')
return table.join(playfield, '\n')
end
return p