-- 此方法能够删除已经require 到内存中的lua文件
function TrackListLayer:removeRequiredByName(preName)
for key, _ in pairs(package.preload) do
if string.find(tostring(key), preName) == 1 then
package.preload[key] = nil
end
end
for key, _ in pairs(package.loaded) do
if string.find(tostring(key), preName) == 1 then
package.loaded[key] = nil
end
end
end
--把表写成lua文件
function TrackListLayer:tableWriteToFile(filename,globlename,pamTable)
local file = nil
if globlename ~= nil then
file = io.open(TrackListLayer.RES_TRUNK..filename,"w+")
file:write("local " .. globlename)
file:write("={\n")
else
file = filename
file:write("{\n")
end
for k,v in pairs(pamTable) do
if type(k) == "number"then
file:write("[")
file:write(k)
file:write("]")
else
file:write(k)
end
file:write("=")
if type(v) == "number" then
local n,f = math.modf(v)
if f == 0 then
file:write(string.format("%d",v))
else
file:write(string.format("%0.2f",v))
end
elseif type(v) == "boolean" then
if v == true then
file:write("true")
else
file:write("false")
end
elseif type(v) == "string" then
file:write("\"")
file:write(v)
file:write("\"")
elseif type(v) == "table" then
self:tableWriteToFile(file,nil,v)
end
file:write(",\n")
end
file:write("}\n")
if globlename ~= nil then
file:write("return ")
file:write(globlename)
file:close()
end
end
-- 此方法能够删除已经require 到内存中的lua文件function TrackListLayer:removeRequiredByName(preName) for key, _ in pairs(package.preload) do if string.find(tostring(key), preName) == 1 then pa...