Fixed Lua 5.2+ errors with backwards compatibility

This commit is contained in:
Timo Smit 2016-08-29 13:27:19 +02:00
parent e8a226cb53
commit 88cf6c1d70
4 changed files with 14 additions and 5 deletions

View file

@ -121,7 +121,7 @@ function admin.onconnect(clientId, firstTime, isBot)
if firstTime then
if stats.get(clientId, "playerGUID") == "NO_GUID" or stats.get(clientId, "playerGUID") == "unknown" then
return "\n\nIt appears you do not have a ^7GUID^9/^7etkey^9. In order to play on this server, enable ^7PunkBuster ^9(use ^7\pb_cl_enable^9) ^9and/or create an ^7etkey^9.\n\nMore info: ^7www.etkey.org"
return "\n\nIt appears you do not have a ^7GUID^9/^7etkey^9. In order to play on this server, enable ^7PunkBuster ^9(use ^7\\pb_cl_enable^9) ^9and/or create an ^7etkey^9.\n\nMore info: ^7www.etkey.org"
end
if db.isconnected() then

View file

@ -17,6 +17,14 @@
local tables = {}
function tables.unpack(table)
if table.unpack ~= nil then
return table.unpack(table)
elseif unpack ~= nil then
return unpack(table)
end
end
function tables.contains(table, needle)
for key, value in pairs(table) do
if value == needle then
@ -37,4 +45,4 @@ function tables.find(table, needle)
return nil
end
return tables
return tables

View file

@ -18,6 +18,7 @@
local constants = require "luascripts.wolfadmin.util.constants"
local util = require "luascripts.wolfadmin.util.util"
local events = require "luascripts.wolfadmin.util.events"
local tables = require "luascripts.wolfadmin.util.tables"
local timers = {}
@ -55,7 +56,7 @@ end
function timers.ongameframe(levelTime)
for id, timer in pairs(data) do
if (et.trap_Milliseconds() - timer["start"]) > timer["interval"] then
timer["function"](unpack(timer["args"]))
timer["function"](tables.unpack(timer["args"]))
timer["iteration"] = timer["iteration"] + 1
if timer["repeat"] == 0 or timer["iteration"] < timer["repeat"] then
@ -68,4 +69,4 @@ function timers.ongameframe(levelTime)
end
events.handle("onGameFrame", timers.ongameframe)
return timers
return timers

View file

@ -45,7 +45,7 @@ function util.escape(str)
end
function util.removeColors(str)
return string.gsub(str, "(\^[%a%d%p])", "")
return string.gsub(str, "(^[%a%d%p])", "")
end
function util.getTeamName(teamId)