Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lunajson = require("ext\\lunajson")
- local EPISODEPATH = Misc.episodePath():gsub([[[\/]+]], [[/]]);
- local SMBXPATH = (Native.getSMBXPath() .. "/"):gsub([[[\/]+]], [[/]]);
- local noGoodEpiosodeFolder = (EPISODEPATH == SMBXPATH)
- local savedata;
- local savepath = EPISODEPATH.."progress.json";
- local function resetAch(index)
- if noGoodEpiosodeFolder then return end
- -- reset the achievement in the Achievements class
- local resettie = Achievements.get(index)
- resettie.__CLTD = false -- has to be this. .collected throws an error on editor exit and fails to change.
- resettie.__PSHWN = false -- same for .popupShown
- for l,m in pairs(resettie.conditions) do
- if(m.conditiontype == "number") then
- resettie.conditions[l].value = 0;
- else
- resettie.conditions[l].value = false;
- end
- end
- -- commit those changes to the file
- savedata = {};
- for k,v in pairs(Achievements.get()) do
- k = tostring(k)
- if(savedata[k] == nil) then
- savedata[k] = {};
- end
- savedata[k].c = v.collected;
- savedata[k].s = v.collected and v.popupShown;
- for l,m in pairs(v.conditions) do
- l = tostring(l);
- if(savedata[k][l] == nil) then
- savedata[k][l] = {};
- end
- if(v.collected) then
- if(m.conditiontype == "number") then
- savedata[k][l].v = m.max;
- savedata[k][l].m = m.max;
- else
- savedata[k][l].v = true;
- end
- else
- savedata[k][l].v = m.value;
- if(m.conditiontype == "number") then
- savedata[k][l].m = m.max;
- end
- end
- end
- end
- local savefile = io.open(savepath, "w+");
- savefile:write(lunajson.encode(savedata));
- savefile:close();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement