Skip to content

Commit

Permalink
Added table.print and io.parseJson to radlib
Browse files Browse the repository at this point in the history
  • Loading branch information
radamanthus committed Aug 30, 2011
1 parent 2b2b6fe commit a300882
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions radlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

module(..., package.seeall)

function io.parseJson( filename )
local file = io.open( filename, "r" )
if file then
local contents = file:read( "*a" )
result = json.decode( contents )
io.close( file )
return result
else
return {}
end
end

-- From: http://stackoverflow.com/questions/1283388/lua-merge-tables
function table.merge(t1, t2)
for k,v in pairs(t2) do
Expand Down Expand Up @@ -34,7 +46,14 @@ function table.filter( t, str )
return result
end

function table.print( t )
for i,v in ipairs(t) do
print(i .. " = " .. v)
end
end

function debug( msg )
native.showAlert("DEBUG", msg, {"OK"})
end


0 comments on commit a300882

Please sign in to comment.