I'm working on a non-Java CC emulator using C# and LuaInterface 2.0.3.

My problem is that this code has problems with bios.lua and coroutine.yield. I tried other native lua codes that use coroutine.yield, these working perfectly, but if I call coroutine.yield inside bios.lua, I'm getting "attempt to yield across metamethod/C-call boundary" error, something like this. (And yes, i know that env["coroutine"] = coroutine is a bad idea)

I tried this too, and works:

SpoilerCode:

print("Do something to continue")
local chr = {coroutine.yield()}
print("i got data")
for k,v in pairs(chr) do print(k,v) end
print("Press a key to continue")
local chr = coroutine.yield("key")
print("go back to main coroutine")
Prints:


Do something to continue
i got data
1	   key
Press a key to continue
go back to main coroutine
Bios is dead, fallback to lua console
The last line is from the native_init.lua, the "main" coroutine

The Real Question:
How can I imorove my sandbox to solve this "attempt to yield across metamethod/C-call boundary" problem?
-or-
What should i edit in the bios.lua to solve this issue?

Details:
.net 3.5
Lua 5.1
Files were extracted from ComputerCraft_1.63.jar

I did not overwrite CC's files and I tried some sandboxes that I've found, but with no luck.

By the way, the "emu" object is an "userdata" and the emu:yield() function is just returning the data from console then returning it.

Edit: I commented out the string.find and string.sub in the bios.lua because native lua is not luaj :P/>