Actions

Module

Editing Parameters

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 54: Line 54:
 
end
 
end
  
local function map(tbl, transform)
+
local function strMap(iter, transform, sort)
 
local returnTable = {}
 
local returnTable = {}
for k, v in pairs(tbl) do
+
for _, v in pairs(iter) do
returnTable[k] = transform(v)
+
table.insert(returnTable, transform(v))
 +
end
 +
if sort then
 +
table.sort(returnTable)
 
end
 
end
return returnTable
 
end
 
 
local function strMap(tbl, transform)
 
local returnTable = map(tbl, transform)
 
 
return table.concat(returnTable)
 
return table.concat(returnTable)
 
end
 
end
Line 82: Line 80:
 
-- Space-pad the parameters to align the equal signs vertically
 
-- Space-pad the parameters to align the equal signs vertically
 
if pad then
 
if pad then
local lengthPerPara = map(parameters, function (parameter)
+
local lengthPerPara = {}
return string.len(parameter) end)
+
for _, parameter in pairs(parameters) do
 +
table.insert(lengthPerPara, string.len(parameter))
 +
end
 
-- Lua doesn't support printf's <*> to specify the width, apparently
 
-- Lua doesn't support printf's <*> to specify the width, apparently
 
local fs = string.format('%%-%ss', math.max(unpack(lengthPerPara)))
 
local fs = string.format('%%-%ss', math.max(unpack(lengthPerPara)))
Line 147: Line 147:
 
%s]],
 
%s]],
 
strMap(Set.valueIntersection(baseParams, otherParams),
 
strMap(Set.valueIntersection(baseParams, otherParams),
function(v) return string.format('* %s\n', v) end),
+
function(v) return string.format('* %s\n', v) end, true),
 
strMap(Set.valueIntersection(baseNormParams, otherNormParams),
 
strMap(Set.valueIntersection(baseNormParams, otherNormParams),
 
function(v) return string.format('* %s < %s [%s]\n',
 
function(v) return string.format('* %s < %s [%s]\n',
Line 153: Line 153:
 
table.concat(otherNormParams[v], '; '),
 
table.concat(otherNormParams[v], '; '),
 
v)
 
v)
end),
+
end, true),
 
strMap(Set.valueComplement(otherNormParams, baseNormParams),
 
strMap(Set.valueComplement(otherNormParams, baseNormParams),
 
function(v) return strMap(baseNormParams[v],
 
function(v) return strMap(baseNormParams[v],
function(s) return string.format('* %s\n', s) end)
+
function(s) return string.format('* %s\n', s) end, true)
end))
+
end, true))
 
end
 
end
  

Please note that all contributions to Unofficial Stationeers Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Unofficial Stationeers Wiki:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)