Better Lua version compatibility.

This commit is contained in:
David Given 2022-07-16 11:54:13 +02:00
parent e564ec311a
commit d5914f2a9e

View file

@ -22,7 +22,7 @@ local loadtarget
-- Compatibility polyfill for load
local function loadf(text, source, mode, env)
if rawget(_G, "loadstring") then
if rawget(_G, "loadstring") and rawget(_G, "setfenv") then
local chunk, e = loadstring(text, "@"..source)
if chunk then
setfenv(chunk, env)