Sorry for my crazy English.
Description
I’m trying to make a simple sequence handling module.
that sequence system works almost exactly the same with this post (thanks to @Pkeod )
when we call the RunEvent(script) function from the outside of the module, It loads up the script as a coroutine,
and coroutine reads and executes functions one by one.
I’ve touched several programming languages, but I’m almost new to Lua.
Problem
Simplified Source code
function event.move(_target,_pos,_duration)
print("[EVENT] Event_Move called. ")
--local pos = go.get_position(_target) + _pos
go.animate(_target, --url
"position.x", --property
go.PLAYBACK_ONCE_FORWARD, --playback
10, --To
go.EASING_LINEAR, --easing
_duration, --duration
0, --delay
function() --callbck
coroutine.resume(event.co)
end)
coroutine.yield()
end
Intended work :
When coroutine called “event.move” function (it animates object which given by arguments),
It animates properly, and when it finished,
calls an anonymous function that resumes the coroutine.
What Actually Happened :
When coroutine called “event.move” function, It animates properly,
But it never calls an anonymous function, and it ends.
Tried list
- I changed
function() coroutine.resume(event.co) end
to
function() print("a") end
- it prints nothing
- I changed the whole
function() coroutine.resume(event.co) end
to
print("test")
- It immediately prints the text “test”. Didn’t wait until the animation ends.