0x0076

From SimsWiki
Revision as of 17:26, 17 September 2012 by Kiwi tea (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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.

Pictorial representation of an array

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.


Using the Instruction Wizard

Array Operation Instruction Wizard

This wizard allows you to choose the specific operation to be performed on your array, and to provide a few extra bits of information depending on which operation you are doing. The various different things you may want to do to an array are discussed below.

Regardless of the operation you are using, you must select whether the array in question is in the object currently known as the My object, or the Stack Object, and you must indicate which array it is since you can have many arrays. They are represented numerically.

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.

Empty the array

You will often start your processing with an array by clearing it of any previous stuff that might be in it. You use the "Clear Contents" operation, remembering to provide details about whether it is the My object, or the Stack Object, and which array number you are talking about.

Find out the size of the array

Having populated your array with a number of values, or perhaps your array having been populated by another BHAV, you may need to know how many boxes have been filled. You can use the "Get size" operation to do this. You provide a variable of your chosing to receive the answer.

Put something into the array

There are a number of ways of writing a value into your array. I think the best way to understand them is by pictures.

Read something out of the array

In order to read something out of the array, without changing the array in any way, you actually use the Expression primitive as follows.

Remove something from the array

See also

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox