-- Licence: MIT Licence -- Some code from the luatz project (MIT Licence) --[[ Utility to delete old chars ]] -- Configuration ========== local dateformat = "%Y-%m-%d, %H:%M" local dateformat_log = "%Y-%m-%d-%H-%M-%S" local FG_Colour_Not_Complete = "#FFB67D" local FG_Colour_Complete = "#000000" local BG_Colour_Not_Complete = "#FFB67D" local BG_Colour_Complete = "#A4FF5A" local Colour_Heading_Complete = "#58FA58" --iup.SetGlobal("UTF8MODE","YES") -- ======================== version= "21" require( "iuplua" ) require( "iupluacontrols" ) dofile "../../SavedVariables/History.lua" function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end -- Minimally effective quoting function quote(astring) return '"' .. string.gsub(astring,"%'", "\\'") .. '"' end function write_saved(o) -- local escaped if type(o) == 'table' then local s = '{\n' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. write_saved(v) .. ',\n' end return s .. '}\n' elseif type(o) == 'string' then return quote(o) else return tostring(o) end end backfile=os.date("History-"..dateformat_log .. ".lua") os.execute( "md ..\\..\\SavedVariables\\History_Bak" ) -- fails silently if already exists. os.execute("copy ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\" .. backfile) newf = assert(io.open("../../SavedVariables/History.new", "w")) -- ============== --Dump it back out -- newf:write("History_SV=" .. write_saved(History_SV)) -- newf:close() --[[ -- ============== Setup storage for old characters. archivef = io.open("../../SavedVariables/History.Archive", "r") if archivef ==nil then --create empty file archivef = io.open("../../SavedVariables/History.Archive", "w") archivef:write("Archive = {} \n") end archivef:close() dofile "../../SavedVariables/History.Archive" -- newf = assert(io.open("../../SavedVariables/History.new", "w")) -- ============== --]] --Dump it back out -- newf:write("History_SV=" .. write_saved(History_SV)) -- newf:close()