0 Favourites

Engine error at "triggerOnShee" in r79.4

  • Geo found an error when using function plugin.

    Geo's test capx has two triggered event(condition), one is "F1", the other is "F2".

    In event(condition) "F1", it will trigger "F2". After running all actions in event(condition) "F1", the engine trigger "F2" again.

    I guess that it might be caused in eveng.js, "triggerOnSheet" function. Check the loop index "i" at line 1581.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • This is a bug in the function object. The way triggers work is triggering "On function" with fn_name = F1 triggers both "On function F1" and "On function F2", with the intent that only "On function F1" returns true. In "On function F1", which is first in the event sheet, "Call F2" sets fn_name = F2 and again Construct 2 triggers both "On function F1" and "On function F2", and this time only "On function F2" returns true. However the value of fn_name has been overwritten, and now execution returns up the stack and Construct 2 is still triggering all "On function" events for the original "Call F1" action. Since fn_name was overwritten to F2 in the nested function call, it should trigger "On function F2" with fn_name = F1, but it's now F2 which returns true and incorrectly runs the event.

    Relevant part of the plugin:

         FunctionKlassProto["_CallC2Event"] = function(name)
         {
            this["fn_name"] = name; // *** overwrites a single value
             this["plugin"].runtime.trigger(cr.plugins_.Rex_Function.prototype.cnds.OnFunctionCalled, this["plugin"]);
         }; 

    Instead you need a stack of state like the event system uses: you need to push the function name to a stack, trigger, then pop the function name from the stack. In 'OnFunctionCalled', only compare to the name at the top of the stack.

  • Ashley

    I got it. Thanks and sorry for wasting your time.

  • No worries :)

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