Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LD31 Script Interface

LD31 Script interface documentation

Global properties

Colors:

Color Colors::Black const
Color Colors::Blue const
Color Colors::Cyan const
Color Colors::Green const
Color Colors::Magenta const
Color Colors::Red const
Color Colors::Transparent const
Color Colors::White const
Color Colors::Yellow const

DateTime:

DateTime DateTime::Now const

Fonts:

Font@ Fonts::DefaultFont const

Inputs:

bool Inputs::Disabled const
bool Inputs::Binding const

Math:

float Math::PI const
float Math::DOUBLE_PI const
float Math::HALF_PI const
float Math::PHI const
float Math::R2D const
float Math::D2R const

Shaders:

bool Shaders::Available const

Funcdefs

void COROUTINE()

Global functions

string formatInt(int64 val, const string&in options, uint width = 0)
string formatFloat(double val, const string&in options, uint width = 0, uint precision = 0)
int64 parseInt(const string&in, uint base = 10, uint&out byteCount = 0)
double parseFloat(const string&in, uint&out byteCount = 0)
float fpFromIEEE(uint)
uint fpToIEEE(float)
double fpFromIEEE(uint64)
uint64 fpToIEEE(double)
bool closeTo(float, float, float = 0.00001f)
bool closeTo(double, double, double = 0.0000000001)
float cos(float)
float sin(float)
float tan(float)
float acos(float)
float asin(float)
float atan(float)
float atan2(float, float)
float cosh(float)
float sinh(float)
float tanh(float)
float log(float)
float log10(float)
float pow(float, float)
float sqrt(float)
float ceil(float)
float abs(float)
float floor(float)
float fraction(float)
string join(const string[]&in, const string&in)
void print(int)
void print(float)
void print(string&in)
void print(const ?&in)
void println()
void println(int)
void println(float)
void println(string&in)
void println(const ?&in)
void CreateCoRoutine(COROUTINE@)
void Sleep(float)
void ObjectType(string&in)

Hook:

void Hook::BindHook(string&in, float = 0)

Inputs:

Input@ Inputs::GetBinding()
void Inputs::StartBind(uint8, bool = true)
Input@ Inputs::GetInput(uint8)

Math:

bool Math::FloatCompare(float, float, float)
int Math::Lerp(int&in, int&in, float)
float Math::Lerp(float&in, float&in, float)
Vec2 Math::Lerp(Vec2&in, Vec2&in, float)
float Math::SlerpAngle(float, float, float)

Resources:

Music@ Resources::GetMusic(string&in)
Buffer@ Resources::GetSound(string&in)
Texture@ Resources::GetTexture(string&in)

Script Objects

array<T>

Factories:

T[]@ array(int&in)
T[]@ array(int&in, uint)
T[]@ array(int&in, uint, const T&in)

Properties:

uint length

Operators:

T& opIndex(uint)
const T& opIndex(uint) const
T[]& opAssign(const T[]&in)
bool opEquals(const T[]&in) const

Methods:

int find(uint, const T&in) const
int findByRef(uint, const T&in) const
void insertAt(uint, const T&in)
void insertLast(const T&in)
bool isEmpty() const
uint length() const
void removeAt(uint)
void removeLast()
void reserve(uint)
void resize(uint)
void reverse()
void sortAsc(uint, uint)
void sortDesc(uint, uint)

Color

Factories:

Color()
Color(uint8, uint8, uint8, uint8 = 255)

Properties:

uint8 A
uint8 B
uint8 G
uint8 R

Operators:

Color& opAssign(Color&in)
Color& opAddAssign(Color&in)
Color& opSubAssign(Color&in)
Color& opMulAssign(Color&in)
Color opAdd(Color&in)
Color opSub(Color&in)
Color opMul(Color&in)
bool opEquals(Color&in)

complex

Factories:

complex()
complex(const complex&in)
complex(float)
complex(float, float)

Properties:

float i
complex ir
float r
complex ri

Operators:

complex& opAddAssign(const complex&in)
complex& opSubAssign(const complex&in)
complex& opMulAssign(const complex&in)
complex& opDivAssign(const complex&in)
bool opEquals(const complex&in) const
complex opAdd(const complex&in) const
complex opSub(const complex&in) const
complex opMul(const complex&in) const
complex opDiv(const complex&in) const

Methods:

float abs() const

DateTime

Factories:

DateTime()
DateTime(int = 0, int = 0, int = 0, int = 0, int = 0, int = 0)

Properties:

uint8 Day const
uint8 Hour const
uint8 Minute const
Month Month const
uint8 Second const
uint16 Year const

Operators:

DateTime& opAssign(DateTime&in)
bool opEquals(DateTime&in)
int opCmp(DateTime&in)
DateTime& opAddAssign(DateTime&in)
DateTime& opSubAssign(DateTime&in)
DateTime opAdd(DateTime&in) const
DateTime opSub(DateTime&in) const

Methods:

string ToString() const

dictionary

Factories:

dictionary@ dictionary()

Operators:

dictionary& opAssign(const dictionary&in)
dictionaryValue& opIndex(const string&in)
const dictionaryValue& opIndex(const string&in) const

Methods:

void delete(const string&in)
void deleteAll()
bool exists(const string&in) const
bool get(const string&in, double&out) const
string[]@ getKeys() const
uint getSize() const
bool isEmpty() const
void set(const string&in, const double&in)

dictionaryValue

Factories:

dictionaryValue()

Operators:

dictionaryValue& opAssign(const dictionaryValue&in)
dictionaryValue& opHndlAssign(const ?&in)
dictionaryValue& opAssign(const ?&in)
dictionaryValue& opAssign(double)
dictionaryValue& opAssign(int64)
void opConv(?&out)
int64 opConv()
double opConv()

file

Factories:

file@ file()

Properties:

bool mostSignificantByteFirst

Operators:

int open(const string&in, const string&in)

Methods:

int close()
int getPos() const
int getSize() const
bool isEndOfFile() const
int movePos(int)
double readDouble()
float readFloat()
int64 readInt(uint)
string readLine()
string readString(uint)
uint64 readUInt(uint)
int setPos(int)
int writeDouble(double)
int writeFloat(float)
int writeInt(int64, uint)
int writeString(const string&in)
int writeUInt(uint64, uint)

Font

Empty class

grid<T>

Factories:

grid<T>@ grid(int&in)
grid<T>@ grid(int&in, uint, uint)
grid<T>@ grid(int&in, uint, uint, const T&in)

Operators:

T& opIndex(uint, uint)
const T& opIndex(uint, uint) const

Methods:

uint height() const
void resize(uint width, uint height)
uint width() const

Input

Properties:

bool Linked const
bool Pressed const
float Value const

Operators:

bool opImplConv()
float opConv()

Methods:

Input@ GetLinked()

Music

Properties:

bool Loops
float Pitch
Status Status const
float Volume

Methods:

void Pause()
void Play()
void Stop()

Rect

Factories:

Rect()
Rect(float, float, float, float)
Rect(Vec2, float, float)
Rect(Vec2, Vec2)

Properties:

Vec2 BottomRight
Vec2 Center const
float Height
float Left
Vec2 Size const
float Top
Vec2 TopLeft
float Width

Operators:

Rect& opAssign(Rect)
bool opEquals(Rect&in)

Methods:

bool contains(Vec2&in)
bool intersects(Rect&in, Rect&out)

Renderer

Properties:

View DefaultView const
Vec2 MousePos const
Vec2 Size const
View View

Methods:

void Clear(Color&in)
void Draw(Rectangle&in, Shader@)
Rect GetViewport(View&in)
Vec2 MapCoordsToPixel(Vec2&in, View&in)
Vec2 mapPixelToCoords(Vec2&in, View&in)

Shader

Properties:

string ID const

Methods:

void SetParameter(string&in, Texture@)
void SetParameterCurrentTexture(string&in)

Sound

Factories:

Sound()
Sound(Buffer@)

Properties:

bool Loops
float Pitch
Status Status const
float Volume

Methods:

Buffer@ GetBuffer()
void Pause()
void Play()
void SetBuffer(Buffer@)
void Stop()

Spinor

Factories:

Spinor()
Spinor(float)
Spinor(float, float)
Spinor(complex&in)

Properties:

float Angle
void Inverted const
float Length
float LengthSquared
void Normalized const

Operators:

bool opCmp(Spinor&in)
Spinor& opAssign(Spinor&in)
Spinor& opAssign(complex&in)
Spinor& opAddAssign(Spinor&in)
Spinor& opSubAssign(Spinor&in)
Spinor& opMulAssign(Spinor&in)
Spinor& opMulAssign(float)
Spinor opAdd(Spinor&in)
Spinor opSub(Spinor&in)
Spinor opMul(Spinor&in)
Spinor opMul(float)

Methods:

float Dot(Spinor&in)
void Invert()
void Normalize()
Spinor Slerp(Spinor&in, float)

Sprite

Factories:

Sprite()
Sprite(Texture@)
Sprite(Texture@, Rect&in)

Properties:

Color Color
Rect GlobalBounds const
Rect LocalBounds const
Vec2 Origin
Vec2 Position
float Rotation
Vec2 Scale
Rect TextureRect

Operators:

Sprite& opAssign(Sprite&in)

Methods:

Texture@ GetTexture()
void Move(Vec2&in)
void Rotate(float)
void Scale(Vec2&in)
void SetOrigin(float, float)
void SetPosition(float, float)
void SetScale(float, float)
void SetTexture(Texture@, bool resetTextureRect = false)

string

Factories:

string()
string(const string&in)

Properties:

uint length

Operators:

string& opAssign(const string&in)
string& opAddAssign(const string&in)
bool opEquals(const string&in) const
int opCmp(const string&in) const
string opAdd(const string&in) const
uint8& opIndex(uint)
const uint8& opIndex(uint) const
string& opAssign(double)
string& opAddAssign(double)
string opAdd(double) const
string opAdd_r(double) const
string& opAssign(float)
string& opAddAssign(float)
string opAdd(float) const
string opAdd_r(float) const
string& opAssign(int64)
string& opAddAssign(int64)
string opAdd(int64) const
string opAdd_r(int64) const
string& opAssign(uint64)
string& opAddAssign(uint64)
string opAdd(uint64) const
string opAdd_r(uint64) const
string& opAssign(bool)
string& opAddAssign(bool)
string opAdd(bool) const
string opAdd_r(bool) const

Methods:

int findFirst(const string&in, uint start = 0) const
int findLast(const string&in, int start = - 1) const
bool isEmpty() const
uint length() const
void resize(uint)
string[]@ split(const string&in) const
string substr(uint start = 0, int count = - 1) const

Text

Factories:

Text()
Text(string&in)
Text(string&in, Font@)
Text(string&in, Font@, uint)

Properties:

uint CharacterSize
Color Color
Rect GlobalBounds const
Rect LocalBounds const
Vec2 Origin
Vec2 Position
float Rotation
Vec2 Scale
string String
uint Style

Operators:

Text& opAssign(Text&in)

Methods:

Vec2 CharacterPos(uint64)
Font@ GetFont()
void Move(Vec2&in)
void Rotate(float)
void Scale(Vec2&in)
void SetFont(Font@)
void SetOrigin(float, float)
void SetPosition(float, float)
void SetScale(float, float)

Texture

Properties:

string ID const
bool Repeated
Vec2 Size const
bool Smooth

Vec2

Factories:

Vec2()
Vec2(float, float)

Properties:

float Angle
float Length
float LengthSquared const
Vec2 Normalized const
Vec2 Perpendicular const
float X
float Y

Operators:

bool opEquals(Vec2&in)
Vec2& opAssign(Vec2&in)
Vec2& opAddAssign(Vec2&in)
Vec2& opSubAssign(Vec2&in)
Vec2& opMulAssign(Vec2&in)
Vec2& opMulAssign(float)
Vec2& opDivAssign(Vec2&in)
Vec2& opDivAssign(float)
Vec2 opAdd(Vec2&in)
Vec2 opSub(Vec2&in)
Vec2 opMul(Vec2&in)
Vec2 opMul(float)
Vec2 opDiv(Vec2&in)
Vec2 opDiv(float)

Methods:

float AngleTo(Vec2&in)
float Distance(Vec2&in)
float DistanceSquared(Vec2&in)
float Dot(Vec2&in)
void Normalize()
void Rotate(float)
Vec2 Rotated(float)

View

Properties:

Vec2 Center
float Rotation
Vec2 Size
Rect Viewport

Methods:

void Move(Vec2&in)
void Reset(Rect&in)
void Rotate(float)
void SetCenter(float, float)
void SetSize(float, float)
void Zoom(float)

Shapes:

Shapes::Circle

Factories:

Circle()
Circle(float, uint = 30)

Properties:

Color FillColor
Vec2 Origin
Color OutlineColor
float OutlineThickness
uint PointCount
Vec2 Position
float Radius
float Rotation
Vec2 Scale
Rect TextureRect

Operators:

Circle& opAssign(Circle&in)
Vec2 opIndex(uint) const

Methods:

Texture@ GetTexture()
void Move(Vec2&in)
void Rotate(float)
void Scale(Vec2&in)
void SetOrigin(float, float)
void SetPosition(float, float)
void SetScale(float, float)
void SetTexture(Texture@, bool resetTextureRect = false)

Shapes::Polygon

Factories:

Polygon()
Polygon(uint)

Properties:

Color FillColor
Vec2 Origin
Color OutlineColor
float OutlineThickness
uint PointCount
Vec2 Position
float Rotation
Vec2 Scale
Rect TextureRect

Operators:

Polygon& opAssign(Polygon&in)
Vec2 opIndex(uint) const

Methods:

Texture@ GetTexture()
void Move(Vec2&in)
void Rotate(float)
void Scale(Vec2&in)
void SetOrigin(float, float)
void SetPoint(uint, Vec2&in)
void SetPosition(float, float)
void SetScale(float, float)
void SetTexture(Texture@, bool resetTextureRect = false)

Shapes::Rectangle

Factories:

Rectangle()
Rectangle(Rect&in)
Rectangle(Vec2&in)

Properties:

Color FillColor
Vec2 Origin
Color OutlineColor
float OutlineThickness
uint PointCount const
Vec2 Position
Rect Rect
float Rotation
Vec2 Scale
Vec2 Size
Rect TextureRect

Operators:

Rectangle& opAssign(Rectangle&in)
Vec2 opIndex(uint) const

Methods:

Texture@ GetTexture()
void Move(Vec2&in)
void Rotate(float)
void Scale(Vec2&in)
void SetOrigin(float, float)
void SetPosition(float, float)
void SetScale(float, float)
void SetTexture(Texture@, bool resetTextureRect = false)

Sound:

Sound::Buffer

Properties:

string ID const

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment