Solasta Scripting Language

## This page is being migrated to Lua. Please bear with us for a few days

Solasta Scripting Language is an attempt to provide a more powerful toolset to Solasta Dungeon Maker authors. It leverages Interative Small Basic (https://github.com/wixette/isb) for its syntax and exposes some functions to interact with the game.

## High-Level Design Patterns

> General Debug Tip:
>
>
> * **utils.message("gadget\_name","") 1**
>
>
> This creates a message on use to aid gadget testing, and can be removed when testing is complete.
>
>

1. Scripts must leave a "true" value in the end otherwise the gadget won't proceed, i.e.:

```
   a. 1
   b. x > y
   c. 0

```

2. Scripts will run whenever a gadget gets an activate signal. There are some collateral cases good to highlight:

* Monsters with AUTO-SPAWN checked will only run the script during location load. You can use that to simulate random monsters when location loads
* Monsters with AUTO-SPAWN unchecked will run the script whenever any other gadget sends and activate signal to it

## The Language

### Data Types

* Strings
* Numbers
* Booleans (any number <> 0 or any string that converted to a number is <> 0)

### Flow Control

```
IF-ELSE-ENDIF
IF-ELSEIF-...-ELSE-ENDIF
WHILE-ENDWHILE
FOR-ENDFOR

```

### Comparison Operations

```
 **<>**

 **<**
 **<=**
 **>**
 **>=**

```

### Boolean Operations

```
 **AND**
 **OR**
 **NOT**
 **PARENTHESES**

```

### Arithmetic Operations

```
 **+**

 **\***
 **/**
 **^**
 **MOD**

```

## The Functions

### Utils

Note that Message and Confirm functions are asynchonous. I cannot afford to block the game waiting for a response. The Confirm function takes a variable name as a parameter and will store a 0 or a 1 as the user response. DON'T TRY TO CHECK THE VARIABLE RIGHT AFTER CALLING CONFIRM! IT'S ASYNCHRONOUS. You gotta come up with other ideas.

1. *NumberValue* **Utils.Random(NumberValue min, NumberValue max)**
2. *Void* **Utils.Message(StringValue confirmationTitle, StringValue confirmationDescription)**
3. *Void* **Utils.Confirm(StringValue confirmationTitle, StringValue confirmationDescription, StringValue variableName, StringValue leftButtonTitle, StringValue rightButtonTitle)**

### Location-Scoped Variables

Persistent across saves, persistent in a particular location.

Locals allow an author to keep a state inside a given location. Note that SET functions will return the new result as a syntax sugar.

1. *NumberValue* **Locals.SetNumber(StringValue variable, NumberValue value)**
2. *NumberValue* **Locals.GetNumber(StringValue variable)**
3. *StringValue* **Locals.SetString(StringValue variable, NumberValue value)**
4. *StringValue* **Locals.GetString(StringValue variable)**

### Campaign-Scoped Variables

Persistent across saves, persistent in the entire campaign.

Globals allow an author to keep a state on the entire campaign. Note that **SET** functions will return the new result as a syntax sugar.

1. *NumberValue* **Globals.SetNumber(StringValue variable, NumberValue value)**
2. *NumberValue* **Glboals.GetNumber(StringValue variable)**
3. *StringValue* **Globals.SetString(StringValue variable, NumberValue value)**
4. *StringValue* **Globals.GetString(StringValue variable)**

### Heroes Data

Gadgets can be interacted by the entire party (area activators or exits) or by a single character (unlocking doors or chests). These functions allow you to determine how many heroes are in a particular interaction knowing hero with index 0 is the one leading it. Use index from 0 to 3 to get access to heroes stats. Use the **Count()** to ensure you won't try to get data from a hero not present in the interaction.

1. *NumberValue* **Heroes.Count()**
2. *StringValue* **Heroes.Name(NumberValue index)**
3. *StringValue* **Heroes.SurName(NumberValue index)**
4. *StringValue* **Heroes.Class(NumberValue index)**
5. *StringValue* **Heroes.Race(NumberValue index)**
6. *StringValue* **Heroes.SubRace(NumberValue index)**
7. *NumberValue* **Heroes.CurrentHitPoints(NumberValue index)**
8. *NumberValue* **Heroes.Lvl(NumberValue index)**
9. *NumberValue* **Heroes.Exp(NumberValue index)**
10. *NumberValue* **Heroes.Str(NumberValue index)**
11. *NumberValue* **Heroes.Dex(NumberValue index)**
12. *NumberValue* **Heroes.Con(NumberValue index)**
13. *NumberValue* **Heroes.Int(NumberValue index)**
14. *NumberValue* **Heroes.Wis(NumberValue index)**
15. *NumberValue* **Heroes.Cha(NumberValue index)**

## Script Library

There are examples of scripts published in the Script Library that you can freely use and remix.

## Help

All Lua scripting is contained within **mapname.lua** and is specific to each map. Remember to remove DEBUG messages when you have finished testing.