Skip to content

Commit

Permalink
Fixed Lua 5.2+ errors with backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Smit committed Aug 29, 2016
1 parent e8a226c commit 88cf6c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion luascripts/admin/admin.lua
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion luascripts/util/tables.lua
Expand Up @@ -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
Expand All @@ -37,4 +45,4 @@ function tables.find(table, needle)
return nil
end

return tables
return tables
5 changes: 3 additions & 2 deletions luascripts/util/timers.lua
Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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
Expand All @@ -68,4 +69,4 @@ function timers.ongameframe(levelTime)
end
events.handle("onGameFrame", timers.ongameframe)

return timers
return timers
2 changes: 1 addition & 1 deletion luascripts/util/util.lua
Expand Up @@ -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)
Expand Down

0 comments on commit 88cf6c1

Please sign in to comment.