26. Make this mean the caller
Use this to reuse one operation on several calling objects. A script called by the lever can treat this as the lever; the same script called by another prop can treat this as that prop. It does not automatically mean the player.
func run(_context: Dictionary = {}) -> Variant:
if this == null:
return false
await SetObjectVisible({"entityId": "this",
"visible": false})
return trueThat example is a small "hide the calling object" operation. Use it only from an appropriate object-owned event. If an editor picker does not offer this, use the text script or structured expression route instead of choosing a random object as a substitute.
| Situation | What to expect |
|---|---|
| Object/character/trigger event | A caller can normally be captured from its entity context. |
| GUI event | this identifies the owning GUI; elementId this has a special route for the calling element. |
| Inventory event | The item can be the owner when its item context is supplied. |
| Ownerless startup/room event | There may be no this record. Check for null. |
| Nested script call | The original captured caller is retained through the call chain. |
| OnCharacterControl | The controlled player can supply the character caller in this special event. |
A structured action targeting this without a caller is skipped with a diagnostic in the checked runtime. It does not silently fall back to the player. The runtime check used for this guide confirmed that behavior.
