(Crazy that Valentine's Day (more or less) is my first post on the Love forums, eh?)
In order to simulate spawning a function in another thread, I'm using Lua coroutines. I'm creating the coroutine as per normal, yielding within a loop that's in the coroutine-ized function, and then resuming at the bottom of my update loop. When it goes to resume, it gives me the error:
attempt to yield across metamethod/C-call boundary
Anyone ever get this? How did you deal with it? Thanks so much for your help
I've never used coroutines, so frankly, I have (almost) no idea.
HOWEVER: The problem might be related to the fact that the main loop is in C. The global functions update and draw are called each frame. I don't have a solution to your problem, but maybe this will give someone else an idea. (FYI: main loop will be in Lua next version).
-- Love.init is the one and only function to be called from C.
-- This function is compiled as Lua-code into the executable, and
-- can't be changed, because it's the function that loads your code (main.lua).
function love.init()
-- loads modules, sets up write directory, and other secret stuff.
-- loads the main.lua file from your game.
-- calls love.run()
end
-- This function is also compiled into the executable, but it is called AFTER main.lua
-- is loaded, so you can overwrite it if you wish.
function love.run()
-- load()
while running do
-- get events, call callbacks
-- update()
-- draw()
end
end
-- You CAN completely ignore the existence of love.run, and use these like normal
-- (yes, they will be moved to the love-table).
function love.load() ... end
function love.update(dt) ... end
function love.draw() ... end
Well, it always made sense to me in the way that those callbacks aren't actually part of the API/SDK/whatever we need to call it provided by love. They are required, but they're not part of.
I don't have a solution to your problem, but maybe this will give someone else an idea. (FYI: main loop will be in Lua next version).
Unless you plan to target something REALLY exotic, your next version could be built on http://luajit.org/coco.html and this issue should never show up.