Skip to content

Instantly share code, notes, and snippets.

@lexnewgate
Created July 22, 2018 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lexnewgate/7815480d9e925678a7f0216cb9ff5b2d to your computer and use it in GitHub Desktop.
Save lexnewgate/7815480d9e925678a7f0216cb9ff5b2d to your computer and use it in GitHub Desktop.
helper functions of lua
--helper funcs
function desc(descp,sep,charn)
sep=sep or "-"
charn= charn or 80
charn= (charn>=#descp) and 80 or #descp
leftseps= math.floor((charn-#descp)/2)
rightseps= charn-leftseps-#descp
writeNChar(leftseps,sep)
io.write(descp)
writeNChar(rightseps,sep)
print()
--io.write("left",leftseps,"right",rightseps,"desc",#descp)
end
function writeNChar(n,char)
for i=1,n do
io.write(char)
end
end
function showTable(table,tableName)
tableName=tableName or ""
desc("showTable "..tableName)
for k,v in pairs(table) do
print(string.format("k=%s (%s)---v=%s (%s)",
tostring(k),type(k),tostring(v),type(v)))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment