Community Curator/Source/TSWRes LoadProcess

LoaderTab = {}

function LoaderTab.LoadFullProfile local ProfileOk = GT.LoadProfile local StoryOk = StoryRes.LoadFile local MMOk = LoaderTab.LoadMyMoonLevels local ComOk = Community.LoadFile if not ProfileOk or not StoryOk or not MMOk or not ComOk then GT.CorruptProfile(ProfileOk, StoryOk, MMOk, ComOk) end end

function LoaderTab.LoadMyMoonLevels if not FS.exists("LBPTSWMyMoon.info") then return true, "No file found" end local BLs = 0 local MyMoonLFile = io.open("LBPTSWMyMoon.info") MyMoonLevels["Levels"] = 0 MyMoonLevels["SavedLevelTab"] = {} print(MyMoonLevels) if MyMoonLFile then local MMLSt = MyMoonLFile:read MyMoonLFile:close if type(MMLSt) == "string" then MyMoonLevels = JSON.DecodeJSON(MMLSt) if type(MyMoonLevels) == "string" then print(MyMoonLevels) MyMoonLevels["Levels"] = 0 MyMoonLevels["SavedLevelTab"] = {} return false, "error" elseif type(MyMoonLevels) ~= "table" then print("error detected while loading MyMoonLevels") MyMoonLevels["Levels"] = 0 MyMoonLevels["SavedLevelTab"] = {} return false, "error" end local SLTab = MyMoonLevels["SavedLevelTab"] if not MyMoonLevels["SavedLevelTab"] then print("error detected while loading MyMoonLevels") MyMoonLevels["Levels"] = 0 MyMoonLevels["SavedLevelTab"] = {} return false, "error" end for k, v in ipairs(MyMoonLevels["SavedLevelTab"]) do           --if v["Size"] = GT.LevelSize(k) if not ok then --table.remove( MyMoonLevels["SavedLevelTab"], k)           end end if (BLs >= #MyMoonLevels["SavedLevelTab"] and BLs ~= 0) then print("Only Broken Levels found!") --MyMoonLevels["Levels"] = 0 --MyMoonLevels["SavedLevelTab"] = {} --LoaderTab.SaveMyMoonLevels end if #MyMoonLevels["SavedLevelTab"] == 0 then os.remove("LBPTSWMyMoon.info") MyMoonLevels["Levels"] = 0 MyMoonLevels["SavedLevelTab"] = {} LoaderTab.SaveMyMoonLevels end else print("Warning: MyMoonLevel File is not a string!") return false, "error" --LoaderTab.SaveMyMoonLevels end else return false, "failed to load file" end return true end

function LoaderTab.SaveMyMoonLevels if type(MyMoonLevels) == "table" then local MyMoonLFile = io.open("LBPTSWMyMoon.info", "w") print("About to Encode") local MMLSt = JSON.EncodeJSON(MyMoonLevels) print(MMLSt) MyMoonLFile:write(MMLSt) MyMoonLFile:close else error("MyMoonLevels is not a table ("..type(MyMoonLevels).."), aborting!") end

end

return LoaderTab