Syntax Guide
AlphaPIL uses a custom scripting syntax inspired by common bot commands and functional programming.
Function Syntax
All functions start with a $ followed by the function name and arguments enclosed in [], separated by ;.
Key Principles
- Top-Down Execution: Templates are processed line by line.
- Case Sensitivity: Function names are case-sensitive (e.g.,
$drawRectvs$drawrect). - Variables: Use
{variable_name}to inject values into arguments. - Colors: Supports hex codes (
#ffffff), RGB/RGBA, and common color names (white,red, etc.).
Function Nesting
One of the most powerful features of AlphaPIL is nesting. Since functions return string values, you can use one function as an argument for another.
How it works
The interpreter resolves functions from the inside-out.
Example:
In this case: 1.$math[100 + 50] is resolved to 150.
2. $random[20;80] is resolved to a random number (e.g., 42).
3. Finally, $drawRect[10;10;150;42;red] is executed.
Composable Functions
Functions that are commonly used inside others include:
* Math & Logic: $math, $if, $random
* Text Utilities: $toUpper, $toLower, $substring, $length
* Color Utilities: $getHex
Advanced Positioning
Anchors (Pivot Points)
Most drawing functions support an anchor parameter. This defines which part of the object "sits" on the coordinates you provided.
| Anchor | Description |
|---|---|
| lt | Left-Top (Default for most) |
| ct | Center-Top |
| rt | Right-Top |
| lm | Left-Middle |
| mm | Middle-Middle (Center) |
| rm | Right-Middle |
| lb | Left-Bottom |
| cb | Center-Bottom |
| rb | Right-Bottom |
Example:
Coordinate Grouping
Groups allow you to define a set of elements relative to a starting point. If you move the group, all elements inside move with it.
$startGroup[100;100]
$drawRect[0;0;50;50;blue] # Drawn at 100,100
$drawCircle[25;25;10;white] # Drawn at 125,125
$endGroup
Variable Management
Setting Variables
You can set internal template variables using $setVar.
Dynamic Injection
When using the Python API, you can pass a dictionary of variables:
In the template:
Mathematical Expressions
Use the $math function to perform calculations.
$setVar[centerX;$math[800 / 2]]
$setVar[centerY;$math[600 / 2]]
$drawCircle[{centerX};{centerY};50;blue]
Logic & Control Flow
If Statements
The $if function allows for conditional rendering.
Syntax: $if[condition;true_branch;false_branch]