mirror of
https://github.com/smogon/sprites.git
synced 2026-08-28 12:47:02 -05:00
{lua,tup}-ext: add trim
This commit is contained in:
@@ -67,3 +67,7 @@ function mergededup(table1, table2, f)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function trim(s)
|
||||
return s:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
|
||||
@@ -46,10 +46,15 @@ end
|
||||
|
||||
function makecmd(cmds)
|
||||
local cmd = ""
|
||||
if cmds.display then
|
||||
cmd = rep{"^ {display}^ ", display=cmds.display}
|
||||
cmds.display = nil
|
||||
for newcmd in iter(flatten(cmds)) do
|
||||
newcmd = trim(newcmd)
|
||||
if cmd ~= "" then
|
||||
cmd = cmd .. " && "
|
||||
end
|
||||
cmd = cmd .. newcmd
|
||||
end
|
||||
if cmds.display then
|
||||
cmd = rep{"^ {display}^ {cmd}", display=cmds.display, cmd=cmd}
|
||||
end
|
||||
cmd = cmd .. table.concat(flatten(cmds), " && ")
|
||||
return cmd
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user