machina = {} local funclist = {} machina.setList = function(...) local yarr = table.pack(...) local errorlist = {} for a = 1, #yarr do if type(yarr[a]) ~= "function" then errorlist[#errorlist+1] = a end end if #errorlist > 0 then local errormsg = "bad argument types: " for a = 1, #errorlist do errormsg = errormsg.."arg"..a.." is "..type(yarr[errorlist[a]]) if a < #errorlist then errormsg = errormsg..", " else errormsg = errormsg.."." end end else funclist = table.pack(...) return true end end machina.startLoop = function() local golly_G = setmetatable({}, {__index=(_ENV or getfenv())}) local funcpos golly_G.coroutine.yield = function(check) if funcpos < #funclist then funcpos = funcpos + 1 local func = funclist[a] func = setfenv(func, golly_G) func() end return table.unpack(evt) end while true do funcpos = 1 local evt = {os.pullEvent()} local func = funclist[a] func = setfenv(func, golly_G) local output = {pcall( function() return func() end )} end end