mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Improve compat code
This commit is contained in:
parent
cb155021b1
commit
29ffa18ff6
7
init.lua
7
init.lua
@ -1,13 +1,14 @@
|
|||||||
-- Lua version check
|
-- Lua version check
|
||||||
if _VERSION then
|
if _VERSION then
|
||||||
|
-- TODO get rid of this string version checking
|
||||||
if _VERSION < "Lua 5" then
|
if _VERSION < "Lua 5" then
|
||||||
error("Outdated Lua version! modlib requires Lua 5 or greater.")
|
error("Outdated Lua version! modlib requires Lua 5 or greater.")
|
||||||
end
|
end
|
||||||
if _VERSION > "Lua 5.1" then
|
if _VERSION > "Lua 5.1" then
|
||||||
-- not throwing error("Too new Lua version! modlib requires Lua 5.1 or smaller.") anymore
|
-- 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
|
unpack = unpack or table.unpack -- unpack was moved to table.unpack in Lua 5.2
|
||||||
loadstring = load
|
loadstring = loadstring or load
|
||||||
function setfenv(fn, env)
|
setfenv = setfenv or function(fn, env)
|
||||||
local i = 1
|
local i = 1
|
||||||
while true do
|
while true do
|
||||||
local name = debug.getupvalue(fn, i)
|
local name = debug.getupvalue(fn, i)
|
||||||
@ -20,7 +21,7 @@ if _VERSION then
|
|||||||
end
|
end
|
||||||
return fn
|
return fn
|
||||||
end
|
end
|
||||||
function getfenv(fn)
|
getfenv = getfenv or function(fn)
|
||||||
local i = 1
|
local i = 1
|
||||||
local name, val
|
local name, val
|
||||||
repeat
|
repeat
|
||||||
|
Loading…
Reference in New Issue
Block a user