Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 4.75 KB

scripting.md

File metadata and controls

75 lines (49 loc) · 4.75 KB

Scripting

< Overview

Stipple Effect lets users write scripts for a range of 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 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.

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.

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

    for (int i = 0; i < letters; 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