Compare commits
2 Commits
34da7e2929
...
68e44e534b
Author | SHA1 | Date | |
---|---|---|---|
68e44e534b | |||
0a21799e60 |
12
lb_store.lua
12
lb_store.lua
@ -17,6 +17,8 @@ local ColdStore = {}
|
||||
-- Livestore are new records nad records loaded from leaderboard.txt file
|
||||
local LiveStore = {}
|
||||
|
||||
-- parse score function
|
||||
local parseScore
|
||||
|
||||
-- GLOBAL
|
||||
-- Returns a list of all maps with records
|
||||
@ -40,13 +42,19 @@ end
|
||||
rawset(_G, "lb_map_list", MapList)
|
||||
|
||||
-- GLOBAL
|
||||
-- Function for adding records from lua
|
||||
-- Function for adding a single record from lua
|
||||
local function AddColdStore(record)
|
||||
ColdStore[record.map] = $ or {}
|
||||
table.insert(ColdStore[record.map], record)
|
||||
end
|
||||
rawset(_G, "lb_add_coldstore_record", AddColdStore)
|
||||
|
||||
-- GLOBAL
|
||||
-- Function for adding a single record in string form from lua
|
||||
local function AddColdStoreString(record)
|
||||
AddColdStore(parseScore(record))
|
||||
end
|
||||
rawset(_G, "lb_add_coldstore_record_string", AddColdStoreString)
|
||||
|
||||
-- Insert mode separated records from the flat sourceTable into dest
|
||||
local function insertRecords(dest, sourceTable, modeSep)
|
||||
@ -204,7 +212,7 @@ local function score_t(map, name, skin, color, time, splits, flags, stat, checks
|
||||
}
|
||||
end
|
||||
|
||||
local function parseScore(str)
|
||||
function parseScore(str)
|
||||
-- Leaderboard is stored in the following tab separated format
|
||||
-- mapnum, name, skin, color, time, splits, flags, stat
|
||||
local t = {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from os import linesep
|
||||
|
||||
@ -86,20 +86,23 @@ with open(coldstore_txt, "w") as f:
|
||||
for score in recordsList:
|
||||
f.write(score + linesep)
|
||||
|
||||
luaA = """local ParseScore = lb_parse_score
|
||||
local AddColdStore = lb_add_coldstore_record
|
||||
local records = {
|
||||
luaA = """do
|
||||
local AddColdStore = lb_add_coldstore_record_string
|
||||
local records = {
|
||||
"""
|
||||
luaB = """}
|
||||
for _, str in ipairs(records) do
|
||||
AddColdStore(ParseScore(str))
|
||||
luaB = """ }
|
||||
for _, str in ipairs(records) do
|
||||
AddColdStore(str)
|
||||
end
|
||||
end
|
||||
"""
|
||||
# pack the records.lua file
|
||||
with open(records_lua, "w") as f:
|
||||
f.write(luaA)
|
||||
for score in recordsList:
|
||||
f.write("\"{}\",{}".format(score, linesep))
|
||||
score = score.replace("\\", "\\\\")
|
||||
score = score.replace("\"", "\\\"")
|
||||
f.write("\t\t\"{}\",{}".format(score, linesep))
|
||||
f.write(luaB)
|
||||
|
||||
# truncate and rewrite rejected scores to leaderboard.txt
|
||||
|
Loading…
Reference in New Issue
Block a user