local Cart = { update = function() end, draw = function() rectfill(0,0,5,5) rectfill(5,0,5,5) rectfill(10,0,5,5) rectfill(0,5,5,5) rectfill(0,10,5,5) rectfill(5,10,5,5) rectfill(0,15,5,5) rectfill(0,20,5,5) end, } sandbox(Cart.draw) local function split(str) local lines = {} for s in str:gmatch("[^\r\n]+") do table.insert(lines, s) end return lines end function Cart:new(o) o = o or {} setmetatable(o,self) self.__index = self return o end function Cart:loadCart(s) local ret = self:new() if not love.filesystem.getInfo(s,"file") then return ret end local code = "" for _,s in pairs(split(love.filesystem.read(s))) do code = code..s.."\n" end 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 return ret end return {Cart=Cart}