(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:
Anyone ever get this? How did you deal with it? Thanks so much for your helpattempt to yield across metamethod/C-call boundary
Code: Select all
function update( dt )
...
resume_coroutines()
end
...
function rotate_enemy(which_enemy, num_angle)
local cur_heading = which_enemy.heading
local goal_heading = which_enemy.heading + num_angle
local angle_increment = num_angle / which_enemy.rate_rotation
while( cur_heading ~= goal_heading )do
cur_heading = cur_heading + angle_increment
which_enemy.heading = cur_heading
coroutine.yield()
end
end
co_rotate_enemy = coroutine.create(rotate_enemy)
...
function resume_coroutines() -- register my coroutines here...
if(coroutine.status(co_rotate_enemy) ~= 'dead' )then
coroutine.resume(co_rotate_enemy)
end
end