Created
July 22, 2018 20:38
-
-
Save lexnewgate/7815480d9e925678a7f0216cb9ff5b2d to your computer and use it in GitHub Desktop.
helper functions of lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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