|Set to Next|
|Game Version:||The Sims 2|
This primitive allows you to cycle through, objects, Pets, Sims, types of things, objects on the same tile as your stack object etc inside the simulation from SimAntics. It is rather like an inbuilt "for loop" of sorts. It has an Instruction wizard to help you use it.
Using the Instruction Wizard
The top half of the wizard covers where you are going to assign the next thing as you loop through them all. This should be familiar to you if you have used Expression [prim 0x0002] when you set the assignment operator (:=). The choices are any of the many variables and attributes that are part of SimAntics.
The bottom half of the wizard deals with what you are enumerating. There is a wonderful selection of different things you can cycle through. Most are self-explanatory. Many reference "temp 0" or another variable, and you are expected to set the appropriate value in that variable before calling the Set to Next instruction. After you have done whatever you are going to do with this instance of the enumerated object, you will loop back, i.e. point an instruction back to this one, to get the next object to work on, and you will loop round all of the items. If Set to Next returns False, there are no more objects and your code will now break out of the loop to wherever you point the False Target on this instruction to.
N.B. Some Set To Next varients have a quirk where they will never return False.
Beware of the "Too many iterations" error. If you zero out the variable you are setting before each call to Set to Next, you are effectively starting the for loop again from the top. So, if you see this error, ensure you are not doing this. Also, always make sure if you are starting an enumeration with Set to Next that the variable you are setting is set to Literal 0. if not, you may find you don't even find the first object.
The various types of items that can be enumerated