Part 2. Put FP objects or textures in array.
If you have many, many objects on table and you want to change at once state of 40, you will use Eval or Execute to itarate thru all. This is just wrong.
It is easier to select that subset of object and put all in one array.
So, i added bunch of helper functions to select subset of FP objects (or BAM textures) and put it into array for later use.
See attached table.
Here is list:
-
GetObjectsRangePreserveIndex (baseName, min, max)
-
GetObjectsRangePreserveIndexWithPostfix (baseName, min, max, postfix)
-
GetObjectsRange (baseName, min, max)
-
GetObjectsRangeWithPostfix (baseName, min, max, postfix)
-
GetObjectsFromList (listOfNames)
-
GetObjectsFromListWithPostfix (listOfNames, postifx)
-
GetObjectsFromListWithExtPostfix(listOfNames)
-
GetTexturesFromList (listOfTextureNames)
You should think not about 8 functions. There are only 3:
GetObjectsRange, GetObjectsFromList, GetTexturesFromList.
Case 1:
GetObjectsRange
Lets say you have 100 bulbs on table. Some have names like this:
bulb101,
bulb102,
bulb103, ....,
bulb122.
You have 22 bulbs and you will want to do something with all that bulbs with one command.
First lets put all 22 bulbs in one array simple way:
Code:
Dim red22bulbs : red22bulbs = GetObjectsRange("Bulb", 101, 122)
That's all. You have array of 22 bulbs ready to use for later.
... and you are not limited to bulbs.... it may be anything in FP with name, flashers, imagelights ....
Case 2:
GetObjectsFromList
Lets say you have:
bulbLeftSligshot,
bulbRighSligshot,
bulbAnotherBuble,
flasher1,
flasherWin.
So, you have 5 objects... they may be even different type, but all are lights and you may want to change
State
property in one line.
No, you can put all that objects in one array with one command:
Code:
Dim fewLights : fewLights = GetObjectsFromList(_
"bulbLeftSligshot, bulbRighSligshot, bulbAnotherBuble,"&_
"flasher1, flasherWin")
Look, i used that underscore character to put bulbs and flashers into 2 different lines, it is easier to read!
Also, you can use spaces between names, so you can format that command to make it easy to read and easy to add more if you need,
Here is screenshot from editor how it looks:

Case 3:
GetTexturesFromList
It is like
GetObjectsFromList. But there is two things to remember:
- In FP texture manager you can add space (one or more) at end of texture name. This will make that texture inaccessible, because before search for texture, all spaces befor and after name are removed.
- If you have typo in texture name, it will be not added to array. If you run table with F9 you will see message
*** Error: texture not found or something like that.
What about other versions?
You have 3 functions with "
WithPostfix" and end of name. They have one more arg at end:
postfix. This is text added to end of object name before you search for it.
Example:
You have same 22 bulbs with names
bulb101,
bulb102,
bulb103, ....,
bulb122. But you want to use that BAM lightExt params. So, you have
xBAM.CreateAllExt
command in script and you search for
bulb101Ext,
bulb102Ext,
bulb103Ext, ....,
bulb122Ext
So, there is postfix at end of object name.... this is why you have that 3 extra functions.
Code:
Dim red22bulbsExt : red22bulbsExt = GetObjectsRangeWithPostfix("Bulb", 101, 122, "Ext")
.... and versions with
PreserveIndex?
Well, with
GetObjectsRange you have 22 bulbs in one array, but to access
bulb106 you need to use
red22bulbs(5).
This may be inconvenient. It is not easy to translate numbers.
So, you have....
PreserveIndex
Code:
Dim red22bulb : red22bulb = GetObjectsRangePreserveIndex("Bulb", 101, 122)
... and you can use it this way:
red22bulb(106).State = BulbOff
But remember, in that array at indexs from 0 to 100 there is nothing!