Scriptable Item

Scriptable Item allows you to script the behavior of an item.


Source Code AssetAn asset can specify the script content that represents the item’s behavior.
Source CodeYou can directly specify the contents of the script that represents the behavior of the item.

The content of the script is written in JavaScript.

Specify either Source Code Asset or Source Code. If both are specified, the content of Source Code Asset takes precedence.

Also, the script length is limited to a maximum of 20KB.


Each item can have at most one Scriptable Item component. It can also coexist with components for other types of items.

See Script Reference for APIs that can be used in scripts.

Other notes

  • Scriptable Items don’t work in world preview
  • Internal state including script variables are reinitialized periodically
    • Use $.state to persist variable changes