# Quick Start

## How to create a new script

To begin you must create a custom command to hold the script. To do this you will need to navigate to:

1. Bot Commands
2. Edit Custom Commands

<figure><img src="/files/QU28lPdo3oH9QYSyxjeA" alt=""><figcaption></figcaption></figure>

Next you need to create a new command.

{% hint style="warning" %}
Make sure to give it a good name. Try not to name it after a regular command that already exists. If you want this script to fire based off a command you will have to title it !command\_name otherwise the name doesn't matter.
{% endhint %}

<figure><img src="/files/mjKtBAO9zbeAzrOZYtqW" alt=""><figcaption></figcaption></figure>

Click the option button on your newly created script, and then select "Edit"

<figure><img src="/files/k7kreoQD42vcW4GyD3Hx" alt=""><figcaption></figcaption></figure>

Now that you have a custom command created, you can turn it into an advanced script holder.

1. Restriction - This is who can activate the command in chat. \
   \
   (This is only relevant if the script is fired by a command in chat. Setting it to caster makes it so only the streamer/broadcaster is able to run this command. If you are linking this to a twitch redemption, leave it on caster.)<br>
2. Run as - This is the trigger start for your script, simple scripts often run as "On Command Call" while more advanced and technical scripts use "On Connect" (Note: "On Connect" makes the script name and Restriction irrelevant.
3. Create Script - This will create the script files and open the folder where they are held so that you can edit them. (Note: the .lua is for code, the .json is for storing settings for the code!)

<figure><img src="/files/XGS9fijouEZ5n66qd0q7" alt=""><figcaption></figcaption></figure>

1. Your Lua script file. You can edit the code in this script while connected! Just press F5 while focusing on the Stream Avatars window to reload the script!
2. Your JSON settings file. This is where you can have data persist between sessions of running Stream Avatars.&#x20;

<figure><img src="/files/1vgQPtBEljoYXHyDOiVB" alt=""><figcaption></figcaption></figure>

## Editing the Script

When you open the script in a text editor, you will be greeted by the boilerplate LUA script which will print out "hello world" to the console log.\
\
You can now click Connect in Stream Avatars so your avatars can spawn and your scripts can run!

{% tabs %}
{% tab title=".lua" %}

```lua
return function()
    log('hello world'); --this will print out 'hello world'
end
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
To view the console log, focus Stream Avatars, and press Alt+C, then type: Lua\
After hitting enter, a console logger will come up showing you the logs.\
Once it is open, you can close the command input by pressing Alt+C again.

You can close the console log by repeating this process.
{% endhint %}

{% hint style="success" %}
**To replay the script or refresh and reload it, focus Stream Avatars, and press the F5 key.**
{% endhint %}

{% hint style="warning" %}
If your custom command is set to Run on: "Command Call", you will need to enter the command into chat. In this example you would type: `my_new_script`
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
