1. You can use concatenations for variable names for (objSetData ...). For example, check out the code for creating wingmen:
Code: Select all
for i 0 (subtract aCount 1)
(block (ship)
(setq ship (sysCreateShip &scCenturion; aStation &svCommonwealth; "fleet"))
(shpOrderEscort ship gPlayerShip i)
; Remember the escorts we assigned
(objSetObjRefData aStation (cat "Wingman" i) ship)
)
)
Notice that the (objSetObjRefData ...) call uses a concatenation of "Wingman" and the loop variable (i) to store each wingman.
2. Looks like you already figured out the syntax for a loop.
3. You can put a data array anywhere. The only constraint is that you cannot have arrays of objects (gStation, for example). That is the reason why there is a separate call for storing objects.
If I want to remember an array, I could do this:
Code: Select all
(objSetData gSource "NumbersFrom1To8"
'(1 2 3 4 5 6 7 8)
)
(You need the quote in front of the array to signify that this is data and not a call to a function called "1")
But if I want to remember a list of objects, then I CANNOT do this
Code: Select all
(objSetObjRefData gSource "MyShips"
'(ship1 ship2 ship3 ship4) ; *WRONG*
)
Instead I need to use the technique I used with wingmen above.
One more thing:
(objSetData ...) attaches data (not objects) to an instance of an object. For example, you might use it to attach data to an INSTANCE of a Tinker station (each Tinker station has different data).
(objSetGlobalData ...) attaches data (not objects) to the class of an object. For example, you might use it to attach data that applies to all Tinker stations. No matter which Tinker station you go to, you will always get the same data.
(staSetGlobalData ...) is the same as the above except that it takes a station type instead of an object pointer. Instead of:
(objSetGlobalData gSource ...)
You can use:
(staSetGlobalData &stTinkerGathering; ...)
[If gSource happens to be a Tinker station, both calls are identical.]
(objSetObjRefData ...) is only used to attach object references to an INSTANCE of an object. There are no equivalents for global data (i.e., there is no way to store an object reference in global data).