Skip to reading
Visual Scripting in Depth

33. Choose a random outcome

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView illustrations

Figure 23. Random Value stores a result. Separate conditions decide what that result means.

1. Add Random Value. Set Minimum 1, Maximum 3 and Whole Numbers true.

2. Set Store in Variable to roll.

3. Add If Compare: {"$var":"roll"} == 1. TRUE goes to the first reply.

4. On FALSE, add another If Compare for roll == 2. TRUE goes to the second reply.

5. The second FALSE route goes to the third reply.

6. Call the graph several times and confirm that every route is valid.

The integer range includes both ends, so 1 through 3 gives three possible values. A floating range produces values between the limits and is better suited to variation in timing or strength than selecting numbered replies.

Random choice does not guarantee that all three results will appear in the first three tests. Use controlled values in the conditions when checking the wiring, then restore the random node.

If each outcome changes persistent state, test each one deliberately. A rare random branch still needs correct item IDs, cleanup and an exit.

Page 37 of 93Permalink
Go to page