Difference between revisions of "0x001F"
MogHughson (Talk | contribs) (→The various types of items that can be enumerated) |
MogHughson (Talk | contribs) (→The various types of items that can be enumerated) |
||
(5 intermediate revisions by one user not shown) | |||
Line 9: | Line 9: | ||
==Using the Instruction Wizard== | ==Using the Instruction Wizard== | ||
[[Image:SetToNextInstructionWizard.JPG|frame|Set to Next Instruction Wizard]] | [[Image:SetToNextInstructionWizard.JPG|frame|Set to Next 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 [[0x0002|Expression [prim 0x0002]]] when you set the assignment operator (:=). The choices are any of the many [[ | + | 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 [[0x0002|Expression [prim 0x0002]]] when you set the assignment operator (:=). The choices are any of the many [[Sims 2 Variables|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. | 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. | ||
Line 16: | Line 16: | ||
− | Beware of the " | + | Beware of the "[[Object Errors#7. Too many iterations|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. |
<br clear="all"/> | <br clear="all"/> | ||
Line 40: | Line 40: | ||
|[[neighbor id]] | |[[neighbor id]] | ||
|- | |- | ||
− | |[[obj with category == param 0]] | + | |[[obj with category|obj with category == param 0]] |
|- | |- | ||
|[[neighbor of type]] | |[[neighbor of type]] | ||
Line 52: | Line 52: | ||
|[[Lot ID]] | |[[Lot ID]] | ||
|- | |- | ||
− | |[[obj with category == temp 0]] | + | |[[obj with category|obj with category == temp 0]] |
|- | |- | ||
|[[person closest to person in temp 0, distance returned in temp 4, relative direction in temp 5.]] | |[[person closest to person in temp 0, distance returned in temp 4, relative direction in temp 5.]] | ||
Line 64: | Line 64: | ||
|[[neighbor id|Neighbor of Family in temp0]] | |[[neighbor id|Neighbor of Family in temp0]] | ||
|- | |- | ||
− | |[[Object of type GUID in temp 0/1]] | + | |[[object of type|Object of type GUID in temp 0/1]] |
|- | |- | ||
|[[Group member of object in temp0]] | |[[Group member of object in temp0]] | ||
Line 107: | Line 107: | ||
|[[Object With Wants Category equal to Temp 0]] | |[[Object With Wants Category equal to Temp 0]] | ||
|- | |- | ||
− | | | + | |[[influence]] |
|- | |- | ||
|[[Neighbor with no relationship to neighbor ID in temp 0]] | |[[Neighbor with no relationship to neighbor ID in temp 0]] |
Latest revision as of 23:43, 11 August 2010
Set to Next | ||
---|---|---|
OpCode: | 0x001F | |
Game Version: | The Sims 2 |
Contents |
[edit] Overview
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.
[edit] 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.
[edit] The various types of items that can be enumerated