I make some effort to preserve order, but deleting results and then readding them appends to the bottom.
V5CVWVALAROQHZ23WC2KISEIHIYD3JEALPQ7P2T7KPOZPIJNGOMAC T2DONXNWMEH4N5S7DVHKA35AHRXWRH3OBFQRS6Z5BHIRVKA5IGJAC UOVX4WJLIAMFNDXXDVZYGS2RCTJYXV2NMKITXN3E3DH7BP5D32DAC R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC 6RN2M65LZLKSK3DJN4TAMLSDRZ3SG7OFDIPQXIYEC66WLII2IBNAC NBRFAEJR4UBMKQ7NSMMDFKVDP7UVIIBQZORVQAPK2W4VFQBVJVKQC S5ADH7USXGZCRISF5TQOAST7RQQ2EUX5QVLFMGVTWTS65KFOO7MAC delete_result = function(from, to)for i=1,#Global_state.results doif eq(Global_state.results[i], {from, to}) thentable.remove(Global_state.results, i)endendend
add_result = function(from, to)table.insert(Global_state.results, {from, to})end
on.quit = function()if Global_state.next_save thensave_results()Global_state.next_save = nilendend
save_results = function()if Results_filename == nil then return endprint('saving to '..Results_filename)local f, err = App.open_for_writing(Results_filename)if err then error(err) endfor _,result in ipairs(Global_state.results) dof:write(('%s beat %s\n'):format(result[1], result[2]))endf:close()end
on.update = function()if Global_state.next_save and Global_state.next_save < Current_time thensave_results()Global_state.next_save = nilendend
Global_state = {} -- just anything we need across functions
-- just anything we need across functionsGlobal_state = {button_handlers = {},next_save = nil, -- if set, timestamp at which to save results to diskresults = {}, -- information about order in which to save to disk}