Skip to content

Lesson 2: Your first SwizzScript

Goal: create a script, turn it on, and see it run.

--! name: First script
--! description: Logs a line when it loads
--! api: 1
swizzin.log("Hello from my first script")
  1. Open Scripts on the toolbar (or type /scripts).
  2. Choose New…, paste the code, and choose Save.
  3. Turn the script On. It needs no permissions, so there is nothing to approve.
  4. Open the Console tab.

The comment lines at the top are the header: name and description appear in the Script Manager, and api: 1 says which API version the script was written for. The last line writes to the Console.

The Console shows Hello from my first script when the script loads.

  • Header lines must start with --! (two dashes and an exclamation mark).
  • The top level of a script must finish within 1 second. Do real work in handlers.
  • Forgetting to turn the script On: every new script starts off.
  • Script shows Needs approval: you added a permissions: line or a call that needs one. Choose Approve and allow.
  • A script written for a newer API than your build is refused: lower api only if you did not use newer features.
  • See Debugging.