Hi, I write a simple plugin to implement 'function' object like in C1.
There is my plugin and test capx.
I call 'runtime.trigger' in acts.CallFunction to trigger cnds.OnFunctionCalled.
acts.CallFunction = function (name)
this._function_name = name;
cnds.OnFunctionCalled = function (name)
return (this._function_name == name);
It works fine, OnFunctionCalled can be triggered correctly.
But, there are something wrong when go back to caller.
I find that in eveng.js, function: run_actions_and_subevents
// Run each action
for (evinfo.actindex = 0, len = this.actions.length; evinfo.actindex < len; evinfo.actindex++)
evinfo.actindex is incorrected when runtime.trigger finished.
In my test case,
evinfo.actindex = 2 when executing action line 3 (Call function).
Event "On function" only has 1 line, so that evinfo.actindex = 1 when leaved.
Now, go back to previous for loop (run_actions_and_subevents). The evinfo.actindex changed to 1 (before was 2)
So that line 3 will be executed again, and again.
Do I miss something about using 'runtime.trigger'?
Oops, you've uncovered an engine bug - triggering from an action does not preserve the current running event. I've fixed it for the next build. If you try again when it's out, it should work.
Develop games in your browser. Powerful, performant & highly capable.
Thanks a lot.
Function plugin test pass in r57, thanks.
Thanks, good to know!