Object type functions

See Classes in Runtime functions for a description of plugins vs. object types vs. instances. Since SOLs (selected object lists) are based on object types, these are also documented below.

Object type properties

type.plugin
A reference to the plugin the object type is from.

type.texture_file
Only valid when pf_texture is specified. The filename of the texture PNG file.

type.texture_filesize
Only valid when pf_texture is specified. The file size of the texture PNG file, generally used to aid the progress bar accuracy.

type.animations
Only valid when pf_animations is specified. Stores the object animations. See Sprite for an example.

type.index
The zero-based index of the object type in the runtime's types_by_index array.

type.instances[]
Array of all the currently created instances of this object type.

type.behaviors[]
Array of all the behaviors added to this object type.

Object type functions

type.getFirstPicked()
Return the first instance of this type. If in an event, this returns the first picked instance, otherwise the first instance in the instances array. Returns null if no instances exist or are picked.

type.getPairedInstance(inst)
inst must be from another object type. Return the instance of this object type that corresponds to inst.

type.getCurrentSol()
Returns the current SOL object. See below.

The SOL

The SOL (selected object list) is the list of all instances currently matching the event. Conditions filter instances matching the condition from the full instance list. In an action, condition or expression, you may wish to access this list (e.g. for static conditions). getCurrentSol() on the object type returns its SOL object, which is documented here.

Remember you must not modify the SOL for any object types other than:
- the current object type in a condition, or
- any object type passed in an object parameter.

You may have read-only access to all other SOLs, though.

SOL properties

sol.type
Reference to the object type the SOL is for.

sol.instances[]
Array of the instances currently matching the event. If sol.select_all is true, this is ignored and may have undefined contents (e.g. arbitrary instances left over from a previous event). Therefore, only use this when sol.select_all is false.

sol.select_all
If true, this specifies that sol.instances must be ignored and sol.type.instances used (the list of all instances). If false, this indicates the contents of sol.instances is the current selection. If setting from true to false, you must clear sol.instances and fill it with your intended content.

SOL functions

sol.hasObjects()
Returns true if the object type has at least one instance and select_all is true, or if the SOL instances array is not empty and select_all is false, else false.

sol.getObjects()
Returns a reference to the current array of instances. If select_all is true, this is the type's array of all instances. If false, this is the SOL's current instances list.

sol.pick(inst)
If select_all is true, sets it to false and picks inst. Otherwise, ensures inst is in the SOL instances array. Note: avoid this function where possible, since it runs in O(n) time and will be slow for large projects.

Tags: