merge upstream
Colors on Non valids. Check msg.to.id and msg.from.id function load_from_file(file) vardump uses serpent tabs on scandir Failed on Free games (no price info) Google with unescaped URLs
This commit is contained in:
@ -116,49 +116,16 @@ function download_to_file(url, file_name)
|
||||
end
|
||||
|
||||
|
||||
function vardump(value, depth, key)
|
||||
local linePrefix = ""
|
||||
local spaces = ""
|
||||
|
||||
if key ~= nil then
|
||||
linePrefix = "["..key.."] = "
|
||||
end
|
||||
|
||||
if depth == nil then
|
||||
depth = 0
|
||||
else
|
||||
depth = depth + 1
|
||||
for i=1, depth do spaces = spaces .. " " end
|
||||
end
|
||||
|
||||
if type(value) == 'table' then
|
||||
mTable = getmetatable(value)
|
||||
if mTable == nil then
|
||||
print(spaces ..linePrefix.."(table) ")
|
||||
else
|
||||
print(spaces .."(metatable) ")
|
||||
value = mTable
|
||||
end
|
||||
for tableKey, tableValue in pairs(value) do
|
||||
vardump(tableValue, depth, tableKey)
|
||||
end
|
||||
elseif type(value) == 'function' or
|
||||
type(value) == 'thread' or
|
||||
type(value) == 'userdata' or
|
||||
value == nil
|
||||
then
|
||||
print(spaces..tostring(value))
|
||||
else
|
||||
print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
|
||||
end
|
||||
function vardump(value)
|
||||
print(serpent.block(value, {comment=false}))
|
||||
end
|
||||
|
||||
-- taken from http://stackoverflow.com/a/11130774/3163199
|
||||
function scandir(directory)
|
||||
local i, t, popen = 0, {}, io.popen
|
||||
for filename in popen('ls -a "'..directory..'"'):lines() do
|
||||
i = i + 1
|
||||
t[i] = filename
|
||||
i = i + 1
|
||||
t[i] = filename
|
||||
end
|
||||
return t
|
||||
end
|
||||
@ -464,4 +431,19 @@ end
|
||||
|
||||
function sleep(n)
|
||||
os.execute("sleep " .. tonumber(n))
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to read data from files
|
||||
function load_from_file(file)
|
||||
local f = io.open(file, "r+")
|
||||
-- If file doesn't exists
|
||||
if f == nil then
|
||||
-- Create a new empty table
|
||||
serialize_to_file({}, file)
|
||||
print ('Created file', file)
|
||||
else
|
||||
print ('Data loaded from file', file)
|
||||
f:close()
|
||||
end
|
||||
return loadfile (file)()
|
||||
end
|
Reference in New Issue
Block a user