From 29ffa18ff610c599aa9ac48cb4ec340adf90dcf4 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Mon, 16 Aug 2021 18:24:11 +0200 Subject: [PATCH] Improve compat code --- init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 9f9d622..ce0c5fa 100644 --- a/init.lua +++ b/init.lua @@ -1,13 +1,14 @@ -- Lua version check if _VERSION then + -- TODO get rid of this string version checking if _VERSION < "Lua 5" then error("Outdated Lua version! modlib requires Lua 5 or greater.") end if _VERSION > "Lua 5.1" then -- not throwing error("Too new Lua version! modlib requires Lua 5.1 or smaller.") anymore unpack = unpack or table.unpack -- unpack was moved to table.unpack in Lua 5.2 - loadstring = load - function setfenv(fn, env) + loadstring = loadstring or load + setfenv = setfenv or function(fn, env) local i = 1 while true do local name = debug.getupvalue(fn, i) @@ -20,7 +21,7 @@ if _VERSION then end return fn end - function getfenv(fn) + getfenv = getfenv or function(fn) local i = 1 local name, val repeat