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: 1swizzin.log("Hello from my first script")- Open Scripts on the toolbar (or type
/scripts). - Choose New…, paste the code, and choose Save.
- Turn the script On. It needs no permissions, so there is nothing to approve.
- Open the Console tab.
What it does
Section titled “What it does”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.
Expected result
Section titled “Expected result”The Console shows Hello from my first script when the script loads.
Common mistakes
Section titled “Common mistakes”- 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.
Troubleshooting
Section titled “Troubleshooting”- 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
apionly if you did not use newer features. - See Debugging.