// C
void main()
{
lua_State * L;
L = lua_open();
luaopen_base(L);
lua_dofile(L, "skript.txt");
for(int i = 0; i < 3; ++i)
{
cout << "Here is main(). Returned value: " << lua_tonumber(L, -1)
<< endl << endl;
lua_dostring(L, "coroutine.resume(co)");
}
}
-- Lua
function yieldtest()
while true do
print("Here is the Lua function")
coroutine.yield(666)
end
end
co = coroutine.create(yieldtest)
coroutine.resume(co)
My question: How can i get the value given to yield() within my program?
And another question:
How can i resume my coroutine other than via lua_dostring(L, "coroutine.resume(co)"); ?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Getting the parameters from yield
Here is my program:
The value is returned by coroutine.resume(co), but is not returned back to C, since you''re not specifying to return any values.
You really shouldn''t bother with the Lua coroutine interface if you''re doing it from C, since coroutines have their own C functions. And there we lead into your second question. Long answer short: lua_resume. Short answer long: RTFM.
How appropriate. You fight like a cow.
You really shouldn''t bother with the Lua coroutine interface if you''re doing it from C, since coroutines have their own C functions. And there we lead into your second question. Long answer short: lua_resume. Short answer long: RTFM.
How appropriate. You fight like a cow.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement