Difference between revisions of "0x0008"

From SimsWiki
Jump to: navigation, search
(Using the Instruction Wizard)
(Using the Instruction Wizard)
 
Line 8: Line 8:
  
 
==Using the Instruction Wizard==
 
==Using the Instruction Wizard==
[[Image:RandomNumberInstructionWizard.JPG|frame|Random Number Instruction Wizard]]
+
[[Image:RandomNumberInstructionWizard.JPG|frame|left|Random Number Instruction Wizard]]
 
The top half of the wizard covers where you are going to assign the generated random number. 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 top half of the wizard covers where you are going to assign the generated random number. 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]].
  

Latest revision as of 10:36, 24 April 2011

Random Number
OpCode:0x0008
Game Version:The Sims 2


[edit] Overview

This primitive allows you to generate a random number inside the simulation from SimAntics, i.e. flip a coin to make random desicions in your BHAV code based upon its result.

[edit] Using the Instruction Wizard

Random Number Instruction Wizard

The top half of the wizard covers where you are going to assign the generated random number. 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 allows you to provide a variable or attribute containing the number to randomise up to, which can also be a literal as in the example above. Note that the number you pick here is exclusive, that is, the top boundary will not be picked as a random number. For a coin toss, i.e. randomise between two numbers, you need to choose Literal 2 as the upper bound. If all you need is a coin toss, there is an alternative Global [BHAV 0x01D2] "Coin Flip" that will randomly return True or False using exactly this instruction.

Your next instruction linked to the True target is likely going to make a descision about what route to take through your BHAV based on what is now contained in your assigned variable.


[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox