runtime functions explanation needed...

For developers using the Construct 2 Javascript SDK

Post » Sat Oct 25, 2014 4:52 pm

Hello! Could someone be so kind to explain me this piece of code from Dictionary plugin or point me to the place where I can read more about it...

Code: Select all
   Cnds.prototype.ForEachKey = function ()
   {
      var current_event = this.runtime.getCurrentEventStack().current_event;
   
      for (var p in this.dictionary)
      {
         if (this.dictionary.hasOwnProperty(p))
         {
            this.cur_key = p;
            this.runtime.pushCopySol(current_event.solModifiers);
            current_event.retrigger();
            this.runtime.popSol(current_event.solModifiers);
         }
      }

      this.cur_key = "";
      return false;
   };


Thanks!
B
6
S
2
Posts: 64
Reputation: 576

Post » Sat Oct 25, 2014 5:11 pm

The most info you can find is from the manual:
https://www.scirra.com/manual/26/runtime

The function basically grabs the current position in the event sheet and runs the subevents from there multiple times. Once for each dictionary key.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Sat Oct 25, 2014 6:58 pm

Thanks @R0J0hound. Do you know where I can read more on pushCopySol(), popSol() and solModifiers?
B
6
S
2
Posts: 64
Reputation: 576

Post » Sat Oct 25, 2014 7:48 pm

No, but from the best I can tell:
solModifiers is the current selected object list state, or something to that effect. Basically what's picked.
pushCopySol() Saves the current sol to a stack.
popSol() Restores what was saved from a stack.

More details about it can be found be poking around the source.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Sat Oct 25, 2014 8:07 pm

OK. Thank you.

For now, I am just "blindly" copy-pasting the Dictionary functionality needed by my plugin :) It works...
B
6
S
2
Posts: 64
Reputation: 576


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests