Difference between revisions of "0x0076"
MogHughson (Talk | contribs) (→Overview) |
MogHughson (Talk | contribs) |
||
Line 6: | Line 6: | ||
==Overview== | ==Overview== | ||
− | In [[SimAntics]] you have various different [[variables]] to store values in. Sometimes you will have need to store many related values, possibly an unknown number (as you loop round something) and so it is infeasible to code to use Local[0], then Local[1], then Local[2] etc. In times like these you should use an array by using the Array Operations [[Primitives|primitive]]. | + | In [[SimAntics]] you have various different [[variables]] to store values in. Sometimes you will have need to store many related values, possibly an unknown number (as you loop round something) and so it is infeasible to code to use Local[0], then Local[1], then Local[2] etc. In times like these you should use an array by using the Array Operations [[Primitives|primitive]]. It has an Instruction wizard to help you use it. |
[[Image:Array.png|frame|Pictorial representation of an array]] | [[Image:Array.png|frame|Pictorial representation of an array]] | ||
Line 17: | Line 17: | ||
==Operations== | ==Operations== | ||
− | There are various things you will want to do to an array which we will cover in this section. You must remember if you decide to use an array, it belongs to an object and that object must be pre-prepared to hold an array - needs space for it. In order to prepare your object for array operations, you must edit the [[OBJD#RAW_Data_-_Data_Space|OBJD Resource, RAW Data section, Data Space]] to tell the object how many arrays you are going to have. | + | There are various things you will want to do to an array which we will cover in this section. |
+ | |||
+ | You must remember if you decide to use an array, it belongs to an object and that object must be pre-prepared to hold an array - needs space for it. In order to prepare your object for array operations, you must edit the [[OBJD#RAW_Data_-_Data_Space|OBJD Resource, RAW Data section, Data Space]] to tell the object how many arrays you are going to have. | ||
===Empty the array=== | ===Empty the array=== | ||
Revision as of 18:20, 26 December 2009
Array Operation | ||
---|---|---|
OpCode: | 0x0076 | |
Game Version: | The Sims 2 |
Contents |
Overview
In SimAntics you have various different variables to store values in. Sometimes you will have need to store many related values, possibly an unknown number (as you loop round something) and so it is infeasible to code to use Local[0], then Local[1], then Local[2] etc. In times like these you should use an array by using the Array Operations primitive. It has an Instruction wizard to help you use it.
An array can hold many values, each one being able to be directly accessed when it is needed.
In the image we have an array containing four values. We could directly access the 2nd element in the array, Box 1, to find out that its value is 7. When using an array in SimAntics you will use what is known as zero-based indexing. This means that the 1st box is called Box 0. Beware when using zero-based indexing with the size of the array. In our picture the array has a size of 4 but there is not a Box 4.
Operations
There are various things you will want to do to an array which we will cover in this section.
You must remember if you decide to use an array, it belongs to an object and that object must be pre-prepared to hold an array - needs space for it. In order to prepare your object for array operations, you must edit the OBJD Resource, RAW Data section, Data Space to tell the object how many arrays you are going to have.