From f3ec32384a0fd755f19ef93493693f9b92054911 Mon Sep 17 00:00:00 2001 From: Not Date: Fri, 20 May 2022 17:35:04 +0200 Subject: [PATCH] use ascii arithmetic to find letter values --- leaderboard.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/leaderboard.lua b/leaderboard.lua index 582769c..bb49758 100644 --- a/leaderboard.lua +++ b/leaderboard.lua @@ -395,8 +395,6 @@ local function mapNotExists(player, map) CONS_Printf(player, string.format("Map doesn't exist: %s", map:upper())) end -local ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - local function changelevel(player, ...) if not doyoudare(player) then return @@ -418,6 +416,8 @@ local function changelevel(player, ...) end local mapnum = 0 + local A = string.byte("A") + if tonumber(p) != nil then -- Non extended map numbers if tonumber(q) == nil then @@ -427,11 +427,12 @@ local function changelevel(player, ...) mapnum = tonumber(p) * 10 + tonumber(q) else --Extended map numbers - p = ALPH:find(p) - 1 + p = string.byte(p) - A local qn = tonumber(q) if qn == nil then - qn = ALPH:find(q) + 9 + qn = string.byte(q) - A + 10 end + mapnum = 36 * p + qn + 100 end