summaryrefslogtreecommitdiffstats
path: root/player/lua/auto_profiles.lua
diff options
context:
space:
mode:
Diffstat (limited to 'player/lua/auto_profiles.lua')
-rw-r--r--player/lua/auto_profiles.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/player/lua/auto_profiles.lua b/player/lua/auto_profiles.lua
index 6856138d97..fba57cc74a 100644
--- a/player/lua/auto_profiles.lua
+++ b/player/lua/auto_profiles.lua
@@ -136,16 +136,20 @@ setmetatable(p, {
})
local function compile_cond(name, s)
- -- (pre 5.2 ignores the extra arguments)
- local chunk, err = load("return " .. s, "profile " .. name .. " condition",
- "t", evil_magic)
+ local code, chunkname = "return " .. s, "profile " .. name .. " condition"
+ local chunk, err
+ if setfenv then -- lua 5.1
+ chunk, err = loadstring(code, chunkname)
+ if chunk then
+ setfenv(chunk, evil_magic)
+ end
+ else -- lua 5.2
+ chunk, err = load(code, chunkname, "t", evil_magic)
+ end
if not chunk then
msg.error("Profile '" .. name .. "' condition: " .. err)
chunk = function() return false end
end
- if setfenv then
- setfenv(chunk, evil_magic)
- end
return chunk
end