Code & Custom UI
back to documentation

Code & Custom UI

Use Function Effects, JavaScript, and custom interfaces when no-code tools are not enough.

UseEffector

UseEffector() asks a known item to run a supported no-code effect immediately. It is useful when a JavaScript Function has made a decision and the visible action belongs on another item.

Keep the call small and explicit. If a normal task connection can express the behavior clearly, prefer the no-code connection.

Required shape

UseEffector(numericItemId, 'EffectName', 'jsonParameters');
  • numericItemId must be the real numeric ID of the target item.
  • EffectName is case-sensitive.
  • jsonParameters is a JSON string. Use '{}' when the effect needs no settings.

A numeric literal is valid:

UseEffector(12345, 'ShowObject', '{}');

When the current item itself is the target, {{Object}} resolves to its numeric item ID:

UseEffector({{Object}}, 'HideObject', '{}');

Do not pass a name, URL, task name, or a JavaScript Function type as the target or effect name.

Safe, supported examples

Show an item

UseEffector(12345, 'ShowObject', '{}');

Hide an item

UseEffector(12345, 'HideObject', '{}');

Show a notification

UseEffector(
  12345,
  'NotificationPill',
  '{"nt":"Door unlocked","c":"34D399","hideBackground":false}'
);

The notification fields are:

Field Meaning
nt Message text
c Hex color, without #
hideBackground Whether to hide the pill background

Change an item’s text

UseEffector(
  12345,
  'ChangeText',
  '{"text":"New objective: find the beacon"}'
);

A safe recipe: reveal a reward after a quest

  1. Put the reward item in the space and record its numeric item ID.
  2. Create a task called RewardReady with the visual behavior you want to inspect in Interactive Studio.
  3. In the JavaScript Function that decides the quest result, check the task numerically.
  4. Call ShowObject only when the condition is true.
if ($TN{FindBeacon} === 2) {
  UseEffector(12345, 'ShowObject', '{}');
  SetTask('RewardReady', 'Active', 0);
}

Replace 12345 with the real reward item ID. Keeping RewardReady as a named task makes the state and follow-up effects visible to other builders.

UseEffector runs immediately

There is no delay argument. To schedule a later visible action, set a task with a delay and put the effect in that task’s no-code flow:

SetTask('ShowRewardLater', 'Active', 3);

Then configure ShowRewardLater to run the appropriate effect. This is easier to inspect than trying to hide timing inside dynamic JSON.

Troubleshooting a failed call

Check these in order:

  1. The target is a real numeric item ID in the current space.
  2. The target item is present and can receive effects.
  3. The effect name matches exactly, including capitalization.
  4. The third argument is valid JSON text.
  5. Start with ShowObject or HideObject and '{}' before adding parameters.
  6. Test in a fresh play session after changing the target item.

What not to do

  • Do not use this API to invoke a JavaScript Function; it only dispatches supported no-code effect types.
  • Do not use it with hidden, internal, or experimental effect types.
  • Do not copy a large JSON payload from an unrelated effect. Configure the visible behavior through normal tasks first.
  • Do not hard-code an ID from another space; item IDs are space-specific.
  • Do not use it as a substitute for an iframe or a browser UI.

For code that chooses when an effect should run, see JavaScript Function overview. For normal task-based effects, see the Interactive Studio documentation.