January 19, 2017

Objects That Contain Collections

There are three main types of collections (poor choice of word here not to be confused with variable types) and there are multiple objects that contain them.

Text

 

Text Category Image
Several objects can be used to enter and display text but not all have a text category. The Text, Enhanced Text and Title objects do. Open a viewer on a Text object and you'll see text in the category list. This provides tiles for manipulating strings. Each character is an element in the collection. The numeric value is a conversion of any consecutive numeric characters into a number and is of a number type not string. In other words you cannot assign string variable value 123 to the Text object's numeric value. Any assignments must match type. Text object "cursor" and Text object "count" are also number types. The cursor can be moved to individual characters and Text "count" can be used in loop creation. All other properties are of type string and string variables can be inserted or appended. To remove characters you can assign a replacement string to an appropriate property. Formatting text has to be done manually through the object's halo options.


Playfield

 

Playfield Collection Category Image
The World, Playfield, Holder, Graph Paper, and X-Y Plane objects can contain any kind of object but they have individual options set that make them useful for different purposes such as the Holder for creating arrays. They have their own co-ordinate systems outside of the world object's and are very useful for assembling other objects. Playfields have a collections category and a playfield category. A cursor can be moved through elements like any other collection. Other than the "count", "cursor",  "numeric value at cursor" and "string contents",  values are of the player type. If you click on the menu icon to the left of the object's "player at cursor" property you'll see an option called tiles to get. This brings up a list of properties from the individual object at the cursor. Not everything from the list is available for every object but you can usually get number, string, color or player tiles from it. This means that you can directly manipulate objects inside collections from playfield type objects. You can also get an assignment tile out of the viewer of the object at the cursor and replace the identifier tile with the "player at cursor tile". This is great for looping through collections and setting or getting values for variables and properties in each object.

Books are special cases that contain pages. Pages themselves are a type of playfield that can contain any object. Books are rather like small presentation applications and have a number of features. I won't go into too much detail here because they are too much fun to explore on their own.


Polygon

Polygon Category Image
Polygons are collections of vertices. Like points vertices have an x and y location but unlike the point type their location cannot be expressed as a point 0@0.  Polygon, Curve, Triangle, Line, Arrow and Curvy Arrow all have polygon categories. Don't confuse Line, Arrow and Curvy Arrow with objects in the Connectors category from the catalogue. Connectors are intended for diagramming and have unique features. Hold the shift key down and left click on Polygon objects to see handles. Move an individual vertex around with the mouse or  add vertices by clicking on the small green triangles and remove them by dragging a vertex over the next closest one. Vertices can only be added to Triangle and Arrow objects with scripting tiles and the Triangle object displays handles by default.

When handles are showing you'll notice that one vertex is blue. Open the viewer, select the polygon category and you'll see the cursor is located at the blue one. Move the cursor and the next vertex becomes blue. You can also see the X and Y value for each vertex. Fun thing to do. Run "shuffle" vertices with a closed polygon. The rest of the tiles are concerned with adding and removing vertices or setting options. I am certain you can do some pretty crazy math related things with these objects but I have done very little experimenting with them so far.

 

Notes on all Types of Collections

 

The cursor always wraps around to the first element if it gets moved past the last element so consider this when designing loops. Make sure decimal point settings match up in object values, variable values and numeric collection values or difficult to detect errors can occur. Forgetting to replace tiles everywhere needed can also cause puzzling errors.



Last Updated  .