Module:SMART attributes: Difference between revisions
From Australian Enthusiasts Wiki
Add test output |
More fixes, seems working now, but will test |
||
| Line 6: | Line 6: | ||
-- Start table | -- Start table | ||
table = "" | table = "" | ||
table = table .. "{|cellspacing=\"0\" cellpadding=\"4\" border=\"1\" style=\"margin: 0 0 1em 1em; border: 1px #171717 solid; border-collapse: collapse; font-size: 90%;\" class=\"wikitable\"" | table = table .. "{|cellspacing=\"0\" cellpadding=\"4\" border=\"1\" style=\"margin: 0 0 1em 1em; border: 1px #171717 solid; border-collapse: collapse; font-size: 90%;\" class=\"wikitable\"" .. "\n" | ||
table = table .. "!width=17%|'''ID'''" | table = table .. "!width=17%|'''ID'''" .. "\n" | ||
table = table .. "!width=17%|'''Name'''" | table = table .. "!width=17%|'''Name'''" .. "\n" | ||
-- Test value | -- Test value | ||
table = table .. "|-" | table = table .. "|-" .. "\n" | ||
table = table .. "|" .. "Foobar" | table = table .. "|" .. "Foobar" .. "\n" | ||
table = table .. "|" .. "Bar" | table = table .. "|" .. "Bar" .. "\n" | ||
for i=1, 254, 1 do | for i=1, 254, 1 do | ||
argName = "" | argName = "" | ||
| Line 27: | Line 27: | ||
if (argName ~= "") then | if (argName ~= "") then | ||
table = table .. "|-" | table = table .. "|-" .. "\n" | ||
table = table .. "|" .. "0x" .. string.format("%x", i) .. "/" .. tostring(i) | table = table .. "|" .. "0x" .. string.format("%x", i) .. "/" .. tostring(i) .. "\n" | ||
table = table .. "|" .. frame.args(argName) | table = table .. "|" .. frame.args(argName) .. "\n" | ||
end | end | ||
end | end | ||
table = table .. "|}" | table = table .. "|}" | ||
return table | return table | ||
end | end | ||
return p | return p | ||
Revision as of 21:46, 3 March 2021
Documentation for this module may be created at Module:SMART attributes/doc
-- Implements Template:SMART attributes.
local p = {}
function p.makeSmartAttrTable()
frame = mw.getCurrentFrame()
-- Start table
table = ""
table = table .. "{|cellspacing=\"0\" cellpadding=\"4\" border=\"1\" style=\"margin: 0 0 1em 1em; border: 1px #171717 solid; border-collapse: collapse; font-size: 90%;\" class=\"wikitable\"" .. "\n"
table = table .. "!width=17%|'''ID'''" .. "\n"
table = table .. "!width=17%|'''Name'''" .. "\n"
-- Test value
table = table .. "|-" .. "\n"
table = table .. "|" .. "Foobar" .. "\n"
table = table .. "|" .. "Bar" .. "\n"
for i=1, 254, 1 do
argName = ""
if (frame.args[string.format("%x", i)] ~= nil) then
argName = string.format("%x", i)
elseif (frame.args[i] ~= nil) then
argName = i
elseif (frame.args["0x" .. string.format("%x", i)] ~= nil) then
argName = "0x" .. string.format("%x", i)
elseif (frame.args["0x" .. string.upper(string.format("%x", i))] ~= nil) then
argName = "0x" .. string.format("%x", i)
end
if (argName ~= "") then
table = table .. "|-" .. "\n"
table = table .. "|" .. "0x" .. string.format("%x", i) .. "/" .. tostring(i) .. "\n"
table = table .. "|" .. frame.args(argName) .. "\n"
end
end
table = table .. "|}"
return table
end
return p