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