diff --git a/lua/quiz/command.lua b/lua/quiz/command.lua index f94b7d2..4ecfdd7 100644 --- a/lua/quiz/command.lua +++ b/lua/quiz/command.lua @@ -60,13 +60,7 @@ function q_command_start(account, filename) end quiz:start(channel.name, filename) - - - i =0 - for t=0,1000000 do - file_save(t, "test.txt") - end - + return 0 end @@ -93,7 +87,7 @@ function q_command_toplist(account) -- load records (if it was not loaded yet) if not q_load_records() then - return 1 + return -1 end local output = localize(account.name, "Top {} Quiz records:", config.quiz_users_in_top) @@ -116,7 +110,7 @@ function q_command_stats(account, username) -- load records (if it was not loaded yet) if not q_load_records() then - return 1 + return -1 end local found = false diff --git a/lua/quiz/quiz.lua b/lua/quiz/quiz.lua index 0b0bce0..e5d32c6 100644 --- a/lua/quiz/quiz.lua +++ b/lua/quiz/quiz.lua @@ -129,7 +129,7 @@ function quiz:stop(username) quiz_display_top_players() else - -- if records.txt is empty then save first records + -- if quiz_records.txt is empty then save first records q_records_total = q_records_current end q_save_records() diff --git a/lua/quiz/records.lua b/lua/quiz/records.lua index 42d4948..6308ce8 100644 --- a/lua/quiz/records.lua +++ b/lua/quiz/records.lua @@ -5,9 +5,13 @@ Licensed under the same terms as Lua itself. ]]-- --- Load total records from records.txt to table +-- Load total records from a text file into the table function q_load_records() - local filename = q_directory() .. "/records.txt" + local filename = config.vardir() .. "quiz_records.txt" + if not file_exists(filename) then + DEBUG("Could not open file with Quiz records: " .. filename) + return false + end if not q_records_total or not next(q_records_total) then -- fill records table return file_load(filename, file_load_dictionary_callback, q_read_records_callback) @@ -18,9 +22,9 @@ function q_read_records_callback(a, b) table.insert(q_records_total, { username = a, points = b }) end --- Save total records from table to records.txt +-- Save total records from the table into a text file function q_save_records() - local filename = q_directory() .. "/records.txt" + local filename = config.vardir() .. "quiz_records.txt" file_save2(filename, q_save_records_callback) end function q_save_records_callback(file) diff --git a/lua/quiz/records.txt b/lua/quiz/records.txt deleted file mode 100644 index e69de29..0000000