Module:SMART attributes

From Computing Classics Wiki
Revision as of 12:00, 3 March 2021 by TheDragonFire123 (talk | contribs) (Remove test attributes and uppercase displayed hex)

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

-- Implements Template:SMART attributes.
local p = {}

function p.makeSmartAttrTable()
	frame = mw.getCurrentFrame():getParent()
	-- 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=5%|'''ID'''" .. "\n"
	table = table .. "!width=29%|'''Name'''" .. "\n"
	
	-- Test value
	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.upper(string.format("%x", i))
    	end
    	
    	mw.log("ITNO " .. tostring(i) .. ", argName = " .. argName)
    	
    	if (argName ~= "") then
    		table = table .. "|-" .. "\n"
    		table = table .. "|" .. "0x" .. string.upper(string.format("%x", i)) .. "/" .. tostring(i) .. "\n"
    		table = table .. "|" .. frame.args[argName] .. "\n"
    	end
 	end

	table = table .. "|}"
	
	return table
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.