Module:Sandbox/Trappist the monk/limits table explained

require ('strict');

local increment_values_t = local id_limits_data_t = ; -- to hold identifier limits from the tabular data file in simple formlocal identifier_order_t = ; -- a sequence of known identifiersfor _, limit_t in ipairs (mw.ext.data.get ("CS1/Identifier limits.tab").data) do -- build a simple table of those limits id_limits_data_t[limit_t[1]] = limit_t[2]; -- is identifier label; is upper limit for that identifier table.insert (identifier_order_t, limit_t[1]); -- add the identifier label to the order listend

table.sort (identifier_order_t); -- ascending sort

--

local function main local update_table = mw.html.create ("table") -- create a wikitable of recommended update values :addClass ("wikitable") :attr ('style', 'float: right; margin-left:0.2em'); -- move it to the right

update_table:node (mw.html.create ('caption'):wikitext ('Suggested update values')); -- add a table caption update_table:node (mw.html.create ("tr") -- create a header row :node (mw.html.create ("th"):attr ('style', 'width: 10em;'):wikitext ("Identifier")) :node (mw.html.create ("th"):attr ('style', 'width: 10em;'):wikitext ("Value")) ); for _, identifier in ipairs (identifier_order_t) do -- spin through the identifiers in order update_table:node (mw.html.create ("tr") -- create a new table row :node (mw.html.create ("td"):wikitext (identifier)) -- add the identifier :node (mw.html.create ("td"):wikitext (id_limits_data_t[identifier] + increment_values_t[identifier])) -- add the recommended value (current value + increment) ); end

return update_table:allDone; -- and doneend

----------------------------< E X P O R T S >----------------------------------------------------------------

return