Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 5.21 KB

scripting.md

File metadata and controls

77 lines (50 loc) · 5.21 KB

Scripting

< Overview

Stipple Effect lets users write scripts for a wide range of potential uses and applications. A script is a short series of instructions for the program to execute.

DeltaScript

Stipple Effect scripts are written in a scripting language called DeltaScript, which was also designed by the developer of the program. DeltaScript is described as a lightweight scripting language skeleton. This means that the DeltaScript base language is easy to learn, with only essential functions in its standard library, and that it is intended to serve as a foundation and be extended upon.

The language was also designed to be powerful, expressive, and concise. The syntax is concise and devoid of boilerplate, and has many shorthands to make scripts shorter without sacrificing readability. It should also be familiar to users with prior programming experience, as the syntax is similar to other C-family languages like C++, Java, JavaScript, and Go.

Do not be discouraged if you have little to no programming experience, or if you are hesitant about learning a new language. There are plenty of resources to familiarize yourself with scripting in Stipple Effect, including:

API

DeltaScript is designed to be extended for the needs of the individual applications that utilize it. As the base language is quite bare, most of the powerful scripting functionality for Stipple Effect is defined in the scripting API - Stipple Effect's extension of DeltaScript. You can read the API specification here.

Types of scripts

Scripts in Stipple Effect scripts fall into the following categories:

Getting Started

Script files and text editor

Script files use the file extension .ses. They can be written in the text editor of your choosing. However, Visual Studio Code (VS Code) is recommended because of the DeltaScript for Stipple Effect syntax highlighting extension that is distributed on the VS Code Marketplace.

Script structure

Scripts consist of a nameless header function, optionally followed by named helper functions. The type signature of the script is the type signature of its header function. Functions can optionally accept parameters and return a value of a specified return type, though neither are required.

Consider the following example script. Given a number of letters n, the script spells a random "word" of n letters. If n <= 0, the script returns the empty string. This script does not utilize any functions or types from the scripting API; it is written exclusively in the DeltaScript base language.

// header function - this is the entry point of the script's execution
// * has a single parameter "n"
// * returns a string
(int n -> string) {
    string word = "";

    for (int i = 0; i < n; i++)
        word += random_letter();

    return word;
}

// helper function "random_letter()"
// * has no parameters
// * returns a char
random_letter(-> char) {
    ~ int MIN = (int) 'a';
    ~ int MAX_EX = ((int) 'z') + 1;

    // "rand" is a function defined by the DeltaScript standard library
    return (char) rand(MIN, MAX_EX);
}

A full breakdown of the syntax and semantics of DeltaScript can be found in the language specification.


SEE ALSO