Files @ r16455:73fedf3e108b
Branch filter:

Location: cpp/openttd-patchpack/source/src/3rdparty/squirrel/samples/coroutines.nut

translators
(svn r21185) -Update from WebTranslator v3.0:
traditional_chinese - 5 changes by josesun
finnish - 17 changes by USephiroth
german - 4 changes by planetmaker
luxembourgish - 5 changes by Phreeze
polish - 5 changes by xaxa
brazilian_portuguese - 2 changes by bmnds
russian - 5 changes by Lone_Wolf
slovak - 4 changes by marek995
spanish - 4 changes by Terkhen
vietnamese - 4 changes by nglekhoi
function coroutine_test(a,b)
{
	::print(a+" "+b+"\n");
	local ret = ::suspend("suspend 1");
	::print("the coroutine says "+ret+"\n");
	ret = ::suspend("suspend 2");
	::print("the coroutine says "+ret+"\n");
	ret = ::suspend("suspend 3");
	::print("the coroutine says "+ret+"\n");
	return "I'm done"
}

local coro = ::newthread(coroutine_test);

local susparam = coro.call("test","coroutine"); //starts the coroutine

local i = 1;
do
{
	::print("suspend passed ["+susparam+"]\n")
	susparam = coro.wakeup("ciao "+i);
	++i;
}while(coro.getstatus()=="suspended")

::print("return passed ["+susparam+"]\n")