Help with SOL

For developers using the Construct 2 Javascript SDK

Post » Tue Nov 04, 2014 6:10 am

I haven't played around with the SOL that much and some things are confusing me a bit since they're not heavily documented.

I'm trying to implement an action which has an object param. What i want to do is be able to loop through all the instances picked by the conditions in the event, this is as basic as it gets i'd imagine. What i'm not sure about is that i can't just take
type.getCurrentSol().instances and loop through the array, because sometimes the list of instances is empty. I'm not really sure what "sol.select_all" does, other than it's true under the basic condition that there are no conditions filtering the type in question, and false if there are conditions filtering the type. I don't know if there's more to "sol.select_all" and the few sentences in the SDK aren't helping me out with more than understanding how it works in basic cases. Also i don't know if theres anything special i have to do to make containers and or/else and inverted conditions work properly. The documentation in the sdk is rather scarce/vague on this topic and i can't find very many examples of actions using the sol within the standard plugins.

I just wanna be on the safe side since my plugin is quite large and small bugs in small features get left behind or missed easily if i don't try my best to implement things robustly from the start.

my current code is:

Code: Select all
   Acts.prototype.ObjAddChild = function (childtype)
   {
   
      var sol = childtype.getCurrentSol();
      var i, leni , inst;
      
      if(sol.select_all) inst = sol.type.instances;
      else inst = sol.instances;
      
      for (i = 0, leni = inst.length; i < leni; i++)
      {
      
         this.obj.add(inst[i].obj);

      };


   };
B
79
S
13
G
8
Posts: 1,977
Reputation: 9,947

Post » Tue Nov 04, 2014 8:26 am

var insts = childtype.getCurrentSol().getObjects();
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Tue Nov 04, 2014 4:10 pm

thanks I missed that!
B
79
S
13
G
8
Posts: 1,977
Reputation: 9,947


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest