Attempt to Yield Across C-Call Boundary

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cmiller114
Prole
Posts: 1
Joined: Sat Jul 05, 2014 11:08 pm

Attempt to Yield Across C-Call Boundary

Post 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
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Attempt to Yield Across C-Call Boundary

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests