Skip to content

Commit

Permalink
Syncing with official mudlet-lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Beliar83 committed May 31, 2011
1 parent c4f1923 commit 3aabb78
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions lua/LuaGlobal.lua
Expand Up @@ -5,14 +5,13 @@

if package.loaded["rex_pcre"] then rex = require "rex_pcre" end
if package.loaded["lpeg"] then lpeg = require "lpeg" end
if package.loaded["zip"] then zip = require "zip" end
if package.loaded["lfs"] then lfs = require "lfs" end

-- TODO this is required by DB.lua, so we might load it all at one place
--if package.loaded["luasql.sqlite3"] then require "luasql.sqlite3" end

json_to_value = yajl.to_value




gmcp = {}

function __gmcp_merge_gmcp_sub_tables( a, key )
Expand All @@ -23,13 +22,57 @@ function __gmcp_merge_gmcp_sub_tables( a, key )
a.__needMerge = nil
end


function unzip( what, dest )
cecho("\n<blue>unpacking package:<"..what.."< to <"..dest..">\n")
local z = zip.open( what )
local createdDirs = {}
for file in z:files() do
local _f, err = z:open( file.filename )
local _data = _f:read("*a")
local _path = dest .. file.filename
local _dir = string.split( file.filename, '/' )
local created = dest;
for k,v in ipairs( _dir ) do
if k < # _dir then
created = created .. '/'.. v;
if not table.contains( createdDirs, created ) then
table.insert( createdDirs, created );
lfs.mkdir( created );
cecho("<red>--> creating dir:" .. created .. "\n");
end
elseif file.uncompressed_size == 0 then
if not table.contains( createdDirs, created ) then
cecho("<red>--> creating dir:" .. file.filename .. "\n")
table.insert( createdDirs, created );
lfs.mkdir( file.filename )
end
end
end
local _path = dest .. file.filename
if file.uncompressed_size > 0 then
local out = io.open( _path, "wb" )
if out then
cecho("<green>unpacking file:".._path.."\n")
out:write( _data )
out:close()
else
echo("ERROR: can't write file:".._path.."\n")
end
end
_f:close();
end
z:close()
end



function onConnect()
end

function handleWindowResizeevent()
function handleWindowResizeEvent()
end

echo("\nLOADING LuaGlobal\n")

local packages = {
"StringUtils.lua",
Expand Down

0 comments on commit 3aabb78

Please sign in to comment.