move Quiz records file into /var/quiz_records.txt

This commit is contained in:
HarpyWar 2014-09-13 12:42:50 +04:00
parent 0c6738fe89
commit 5f171df203
4 changed files with 12 additions and 14 deletions

View file

@ -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

View file

@ -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()

View file

@ -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)

View file