Clear all SOLs

0 favourites
  • 7 posts
From the Asset Store
Basics sprites and tilesets to build a platformer game or prototype
  • Is there a convenient way that i can empty every SOL ? i have a condition that picks objects in an advanced way that first requires all the sols for all objects except the one calling the condition to be empty (it then picks a specific subset of objects).

    the condition basically needs to work as follows

    Condition:

    "Main object -> pick children"

    {

    wipe all SOLs except possibly the sol of "Main object" which is calling the condition.

    iterate over children of main object, adding them to sol.instances.

    return true.

    };

  • Maybe something like this should work?

    for (i = 0, len = runtime.types_by_index.length; i < len; i++)
    {
    	var type = runtime.types_by_index[i];
    	var sol = type.getCurrentSol();
    	sol.select_all = false;
    	sol.instances.length = 0;
    }[/code:2lz1vgzb]
    It's untested but should work as types_by_index is used elsewhere to loop over the types.  You'll probably need to save the old SOL first with pushCleanSol() or something like that.  You can find it in preview.js as well as examples of it's use.  
    
    You may need to do some experimenting with it as I don't know if doing that will cause issues with the event sheet, since the standard behavior is to terminate evaluating and other sub-events if 0 of something is picked.  I could be wrong but it's just a thought.
  • This is how i was doing it but i didn't know what the type's list was called so i was grabbing all the children's types through the instances that were children. gonna try this now and see what happens.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should avoid this kind of thing for performance reasons. Since you have code that runs for each unique type in the project, you will have a slowdown proportional to the size of the project, and we've had bugs reported (and fixed them) based on accidentally having code like that which slows down large projects.

    Also in the event engine you are not actually allowed to modify the SOL of any objects apart from your own or anything passed in object parameters to the current condition/action. Doing so will break the event engine optimisations aimed at avoiding the above performance problem.

  • Ashley

    Or provide more high level SOL functions for picking in SDK, to indicate event engine here has SOL changing?

    I would like to have some picking in my plugins which could be more compactly.

  • It's hard to provide many useful "general purpose" functions without incurring a serious performance penalty, or having to make some significant changes to how the engine predicts which SOLs are going to be modified.

  • i think a nice solution would be to have a param where you can let users select multiple types or none at all at once for certain conditions, and then the param in the run-time function is an array of the types which a user has selected? this way we could make flexible functions that operate on many types, but only as many as the user selects, circumventing the issue of slowdown proportional to a large number of types in the project for stuff like this?

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