Skip to reading
Visual Scripting in Depth

23. Make the pickup safe to repeat

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 PDF page

1. Set key_taken to false in Variable Designer for a fresh game.

2. Place the If Variable guard before Give Item and Add Score.

3. Set key_taken true as part of the successful pickup.

4. Assign the graph only to the intended pickup response.

5. Test the successful pickup. You should gain one item and five points.

6. Call it again during testing. The guard should produce the already-collected response without another reward.

Hiding the key usually prevents another ordinary click, but the flag still matters. Another script, an event, a saved room state or a later change could call the same pickup logic again.

Source table from 23. Make the pickup safe to repeat, page 27
After a fresh runExpected state
Before pickupkey_taken false; key quantity 0; score 0.
After first pickupkey_taken true; quantity 1; score 5; scene key hidden.
After repeated callSame quantity and score.
After leaving and returningThe supported room/puzzle state remains consistent.

For a longer asynchronous pickup sequence, consider a busy guard as well. Set busy before the first wait, reject overlapping starts and clear it on every completion path. This prevents two calls from both passing an initial test while the first is suspended.

A one-time flag and a temporary busy flag solve different problems. Keep the permanent completion flag even after adding a busy guard.

Page 27 of 93Permalink
Go to page