Fix cart loading...?

It's not working but it's at least correctly loading. Just having issues, ya know, running the damn code.
This commit is contained in:
Robert Miles 2018-08-05 16:24:48 -04:00
parent 098dd64e81
commit e2a55bed98
2 changed files with 4 additions and 5 deletions

View File

@ -27,10 +27,9 @@ function Cart:loadCart(s)
for _,s in pairs(split(love.filesystem.read(s))) do
code = code..s.."\n"
end
code = "return (_update or function() end),(_draw or function() end)\n"
local ok,err = pcall(loadstring,code)
if not ok then error(err) end
sandbox(err)
code = code.."return (_update or function() end),(_draw or function() end)\n"
local ok,err = pcall(loadstring,code,'t',sandbox())
if not ok then print(err) return ret end
update, draw = err()
ret.update = update
ret.draw = draw

View File

@ -8,7 +8,7 @@ function _G.sandbox(f)
for k,v in pairs(api) do
glob[k]=v
end
setfenv(f,glob)
if f then setfenv(f,glob) else return glob end
end
local Cart = require("cart").Cart
local cart