参考: はじめてのLuaプログラミング―人気の軽量スクリプトでアプリケーション開発! (I・O BOOKS), pp.260-276
function on.construction() var.store("k", 0) end function test() while true do for i = 1, 5, 1 do var.store("k", i) coroutine.yield() end for i = 4, 2, -1 do var.store("k", i) coroutine.yield() end end end co_test = coroutine.create(test) function on.mouseUp() coroutine.resume(co_test) end function on.enterKey() coroutine.resume(co_test) end