SOL, Object Scopes, and all that.



60 visits, 74 views


This tutorial hasn't been translated.



Wake up sheeple, Construct is FOOLING YOU.

Programming doesn't work the way Construct wants you to believe. It actually does some super shady stuff behind the scenes so you feel comfortable and trust it.

if(Enemy.HP = 0) then Enemy.Die() doesn't magically pick every enemy objects that have 0 HP and kills them.

What Construct actually does is understand that what you're actually meaning to do is pick every Enemies, check which ones have a HP value of 0 and execute the code for them only.

That process of choosing which objects to execute stuff on is named "Object scoping", and the thing that holds that information is named the SOL (Selected Objects List).

There are a few things to know about the SOL and how it works:

Each object type has its own SOL. Meaning picking Enemies doesn't affect how your Players are picked.

That includes Families. Picking Family objects doesn't automatically pick linked object types in said family.

By default, every object is in the SOL.

The SOL is passed down to sub events. To reset an object type's SOL, use the system "Pick all" condition

When creating an object, that object's type's SOL gets overwritten to contain only that created object for that event block.

When I say "that event block" I also mean its sub events.

Functions don't keep the SOL from where they were called.

SOL is updated using conditions from TOP TO BOTTOM and will execute the following conditions as long as the SOL isn't empty.

Properly picking your instances will be your #1 tool for reducing code complexity in your Construct Code.

If you're looping over every instance of an object and then making checks, you should probably moving these checks above your for each loop to avoid some instances getting needlessly looped over.

Additional must reads

How Scopes work in Multimedia Fusion, its más o menos the same in Construct:

Some required knowledge concerning containers:

Picking using System conditions (search for "PICK INSTANCES"):

Next Tutorial In Course

The tickcount trick 01:12

TL;DR: tickcount%2 = 0


  • Order by
Want to leave a comment? Login or Register an account!