Skip to reading
Visual Scripting in Depth

26. Reuse a graph with “this”

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 18. The shared switch graph stores the event target, then disables this rather than a hard-coded switch ID.

1. Create blue_switch and red_switch as separate scene objects.

2. Create one switch_self graph with On Interact: use.

3. Add Enable / Disable Object. Choose this as the object and set Enabled false.

4. Assign the same graph to the Use verb on both switches.

5. Use the blue switch. Only the blue switch should disable.

6. Use the red switch. Only the red switch should disable.

this refers to the captured owner of the event that called the graph. It is not the object selected in the editor. It is also different from player, which resolves to the currently active player character.

A direct editor test may have no owning object. In that case this cannot resolve; the action is skipped with a diagnostic. Test this through a real owner event, or supply an explicit target for an owner-independent utility.

A GUI event’s owner is the GUI, not a nearby scene object. Use a specific object ID or an entity parameter when a GUI button should change an object in the room.

Page 30 of 93Permalink
Go to page