TWU Script

### Tips And Tricks

* Holding the Shift key while inserting a band will insert it above your currently selected band
* One band counts as one line; Lines are **one-based**.
* Indexes are also **one-based**
* Try to keep your scripts as linear as possible, use if-then-exit blocks
* You can find TWU Script - Case Studies here

### About Bands

TWU scripts are structured into so called bands. They are you basic programming blocks and serve a purpose. Bands can have **tags** to which you can jump, as well as quest key conditions.

Bands are always executed in a sequential order, top to bottom. Take this simple script, for example:

It breaks down like this:

* Prompt the player for "Left", "Right" or "Nevermind"
	+ Nevermind will cancel the script
	+ "Left" or "Right" will advance to the if...then band
* If last option index is...
	+ ...1 then the left door is opened
	+ ...not 1 then the right door is opened
* Lastly, a text is displayed to the user, with a cancel action being the only outcome.

Keep this sequential execution order in mind for any scripts you build.

### Available Bands

#### Display Text

The **Display Text** band allows you to display a text to the user, along with two potential actions: Advance and Cancel.

The **Advance** action will have the script advance to the next band. The **Cancel** action will exit the script at this point. You may leave either of the two blank and the option will not be presented to the player.

#### Display Options

The **Display Options** band is a more elaborate form of the **Display Text** band. It allows you to display several options to the player.

Options in the option field are seperated by a **;**. Any of the available options will advance the script to the next band, whereas the **Cancel Action** will cancel it.

You can now use the options in an **if-band** to check for either the option value or the option index:

#### Random Band

The Random value bands generates a random value from **from** to **to.** The resulting random value can be checked with the **if band** and the **Last random value** check.

The generated random value is inclusive in both bounds, lower and upper. A random band like this:

Would generate the values one, two and three.

#### Check Quest Cooldown

The check quest cooldown band allows you to create an early-return point in your script. The band will effectively prevent all following bands from being executed when a quest is on cooldown.

You need to use this in combination with the **finish quest** band by providing a cooldown. Here is an example of a simple loop that can only be executed every minute.

```
{"Version":"1.1","ScriptId":"565996288","Name":"Simple Quest Cooldown","Category":"","Microscript":false,"Parts":[{"PartId":"685506752","StepType":2.0,"A":"Sorry, Quest still on cooldown!","B":"Q\_SIMPLE\_01","C":"Oh no :(","V":0.0,"N":"","Condition":{"Key":"None","Operator":1.0,"Value":0.0}},{"PartId":"741141952","StepType":0.0,"A":"Start the quest!","B":"Yes!","C":"No?","V":0.0,"N":"","Condition":{"Key":"None","Operator":1.0,"Value":0.0}},{"PartId":"666127488","StepType":7.0,"A":"","B":"11501||<1","C":"","V":0.0,"N":"","Condition":{"Key":"None","Operator":1.0,"Value":0.0}},{"PartId":"481368448","StepType":3.0,"A":"Q\_SIMPLE\_01","B":"","C":"","V":60.0,"N":"","Condition":{"Key":"None","Operator":1.0,"Value":0.0}}]}

```