[Solved]How do I use "runtime.trigger" in plugin?

0 favourites
  • 5 posts
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • Hi, I write a simple plugin to implement 'function' object like in C1.

    There is my plugin and test capx.

    dl.dropbox.com/u/5779181/plugins.7z

    I call 'runtime.trigger' in acts.CallFunction to trigger cnds.OnFunctionCalled.

         acts.CallFunction = function (name)
         {
            this._function_name = name; 
           ??this.runtime.trigger(cr.plugins_.MyFunction.prototype.cnds.OnFunctionCalled, this);
         }; 
         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++)
              {
                  ?if (this.actions[evinfo.actindex].run())
                        return;
              }

    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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks a lot.

  • Function plugin test pass in r57, thanks.

  • Thanks, good to know!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)