Page 1 of 1

Attempt to Yield Across C-Call Boundary

Posted: Sat Jul 05, 2014 11:26 pm
by cmiller114
Hey all, new here. Not a great programmer by any means, but thought I'd try my hand at an RPG anyway. I don't know how people typically do these things, but I just pull all the NPC data from a table in a file, a table which includes a function that occurs when the protagonist collides with an NPC. Anyway, the one NPC in the source below (he's the only one standing) will prompt a messagebox, and after pressing 'T', the hero will move to a different location in the map (just testing). After doing this once, or multiple times, I get a blue screen which says "Attempt to Yield Across C-Call Boundary". I've tried to look up what this means and I have failed. I have never used coroutines before, so I'm sure I'm just yucking something up.

The pertinent code is as follows. The following is the function in the table in the file I pull from:

Code: Select all

confront = function()
	msgbox.msg ="Poop is brown"
	msgbox.visible = true
	scenepause = true
	while scenepause == true do coroutine.yield() end
	heromapx = 500
end
And then upon touching an NPC, I pull that function into activescript as a coroutine in love.update:

Code: Select all

	if npcconfront ~= 0 then activescript = coroutine.create(script.npcs[npcconfront].confront)	end
And then I continually run activescript at the end of love.update until the coroutine is dead:

Code: Select all

	if coroutine.status(activescript) then coroutine.resume(activescript) end
Again, I apologize that my code is so ugly!

Here's the LOVE file: http://www.cucprogramtracker.com/rpg%20game.love

Re: Attempt to Yield Across C-Call Boundary

Posted: Sun Jul 06, 2014 8:09 am
by bartbes
You run confront even without a coroutine.resume, sometimes, and because you've got an npc that yields, nothing's "catching" that, and you end up "yielding" back to the engine before it stops it. Also, please indent your code.