1
0
mirror of https://github.com/kepler155c/opus synced 2025-12-18 22:28:06 +00:00
This commit is contained in:
kepler155c@gmail.com
2017-10-23 19:33:53 -04:00
parent 22a432492c
commit 84b2b8ce63
6 changed files with 27 additions and 89 deletions

View File

@@ -262,7 +262,9 @@ end
function Util.size(list)
if type(list) == 'table' then
local length = 0
table.foreach(list, function() length = length + 1 end)
for _ in pairs(list) do
length = length + 1
end
return length
end
return 0
@@ -433,8 +435,7 @@ function Util.runUrl(env, url, ...) -- os.run equivalent
setmetatable(env, { __index = _G })
local fn, m = Util.loadUrl(url, env)
if fn then
local args = { ... }
return pcall(function() return fn(table.unpack(args)) end)
return pcall(fn, ...)
end
return fn, m
end
@@ -443,8 +444,7 @@ function Util.run(env, path, ...)
setmetatable(env, { __index = _G })
local fn, m = loadfile(path, env)
if fn then
local args = { ... }
return pcall(function() return fn(table.unpack(args)) end)
return pcall(fn, ...)
end
return fn, m
end
@@ -452,9 +452,7 @@ end
function Util.runFunction(env, fn, ...)
setfenv(fn, env)
setmetatable(env, { __index = _G })
local args = { ... }
return pcall(function() return fn(table.unpack(args)) end)
return pcall(fn, ...)
end
--[[ String functions ]] --