Files
simian/scripts/as.predefined
T
nick bc99a1e53c
CI / build-and-test (push) Successful in 2m41s
Sync Docs to Gitea Wiki / Sync docs to Gitea wiki (push) Successful in 11s
feat: Globals value store as well
2026-03-13 14:50:53 +13:00

360 lines
14 KiB
Plaintext

typedef void string;
string format(const string&in fmt, const ?&in ...);
// Array template (provided by scriptarray add-on)
external shared class array<T> {
uint length() const;
void resize(uint);
void insertAt(uint, const T&in);
void insertLast(const T&in);
void removeAt(uint);
void removeLast();
T& opIndex(uint);
const T& opIndex(uint) const;
}
// Logging functions
void Print(const string&in);
void Log(int level, const string&in);
int LOG_TRACE;
int LOG_DEBUG;
int LOG_INFO;
int LOG_WARNING;
int LOG_ERROR;
int LOG_FATAL;
// Toast notification functions
namespace Toast {
void Info(const string&in msg);
void Warning(const string&in);
void Error(const string&in);
void Success(const string&in);
}
// ECS functions
namespace ECS {
// Entity management
uint CreateEntity();
void DestroyEntity(uint entity);
bool IsValid(uint entity);
// Transform component
void AddTransform(uint entity, float x, float y, float z);
void SetPosition(uint entity, float x, float y, float z);
void GetPosition(uint entity, float &out x, float &out y, float &out z);
void SetScale(uint entity, float x, float y, float z);
void SetRotation(uint entity, float rotation);
void SetRotationEuler(uint entity, float x, float y, float z);
float GetRotation(uint entity);
void GetRotationEuler(uint entity, float &out x, float &out y, float &out z);
bool HasTransform(uint entity);
void RemoveTransform(uint entity);
// Velocity component
void AddVelocity(uint entity, float vx, float vy, float vz, float angular = 0.0f);
void SetVelocity(uint entity, float vx, float vy, float vz);
void SetAngularVelocity(uint entity, float angular);
bool HasVelocity(uint entity);
void RemoveVelocity(uint entity);
// ModelRenderer component
void AddModelRenderer(uint entity, int modelId, uint color, float outlineSize = 0.0f);
void SetModelRendererColor(uint entity, uint color);
void SetModelRendererModel(uint entity, int modelId);
void SetModelRendererOutline(uint entity, float outlineSize);
void SetModelRendererShader(uint entity, uint shaderId);
bool HasModelRenderer(uint entity);
void RemoveModelRenderer(uint entity);
// Texture component
void AddTexture(uint entity, uint textureId);
void SetTextureId(uint entity, uint textureId);
uint GetTextureId(uint entity);
bool HasTexture(uint entity);
void RemoveTexture(uint entity);
// UV transform component
void AddUVTransform(uint entity, float scaleX, float scaleY, float offsetX = 0.0f, float offsetY = 0.0f, float rotation = 0.0f);
void SetUVScale(uint entity, float scaleX, float scaleY);
void SetUVOffset(uint entity, float offsetX, float offsetY);
void SetUVRotation(uint entity, float rotation);
bool HasUVTransform(uint entity);
void RemoveUVTransform(uint entity);
// Tag component
void AddTag(uint entity, const string &in name);
string GetTag(uint entity);
void SetTag(uint entity, const string &in name);
bool HasTag(uint entity);
void RemoveTag(uint entity);
// Hierarchy component
void SetParent(uint child, uint parent);
void ClearParent(uint child);
uint GetParent(uint child);
bool HasParent(uint child);
// Camera3D component
void AddCamera3D(uint entity, float px, float py, float pz, float tx, float ty, float tz, float fovy);
void SetCameraPosition(uint entity, float x, float y, float z);
void SetCameraTarget(uint entity, float x, float y, float z);
void SetCameraFovy(uint entity, float fovy);
bool HasCamera3D(uint entity);
void RemoveCamera3D(uint entity);
// Light component
void AddLight(uint entity, float dx, float dy, float dz, float intensity = 1.0f);
void SetLightDirection(uint entity, float x, float y, float z);
void SetLightIntensity(uint entity, float intensity);
void SetLightColor(uint entity, uint color);
bool HasLight(uint entity);
void RemoveLight(uint entity);
// Material component
void AddMaterial(uint entity, uint materialId);
void SetMaterialId(uint entity, uint materialId);
uint GetMaterialId(uint entity);
bool HasMaterial(uint entity);
void RemoveMaterial(uint entity);
// RenderPass component
void AddRenderPass(uint entity, int order, bool depthTest, bool depthWrite, uint shaderId);
void SetRenderPassOrder(uint entity, int order);
void SetRenderPassShader(uint entity, uint shaderId);
bool HasRenderPass(uint entity);
void RemoveRenderPass(uint entity);
}
// Shader resource management
namespace Shader {
uint Load(const string &in vsPath, const string &in fsPath);
void Unload(uint id);
}
// Model resource management
namespace Model {
uint Load(const string &in path);
uint LoadCube(float width, float height, float length);
uint LoadSphere(float radius, int rings, int slices);
uint LoadPlane(float width, float length, int resX, int resZ);
void Unload(uint id);
}
// Material resource management
namespace Material {
uint Create(uint shaderId, uint8 r, uint8 g, uint8 b, uint8 a);
void Remove(uint id);
void SetShader(uint id, uint shaderId);
void SetAlbedo(uint id, uint8 r, uint8 g, uint8 b, uint8 a);
}
// Asset manager (keyed assets)
namespace Asset {
uint LoadTexture(const string &in key, const string &in path);
uint LoadShader(const string &in key, const string &in vsPath, const string &in fsPath);
uint LoadModel(const string &in key, const string &in path);
uint LoadCube(const string &in key, float width, float height, float length);
uint LoadPoly(const string &in key, int sides, float radius);
uint LoadSphere(const string &in key, float radius, int rings, int slices);
uint LoadHemiSphere(const string &in key, float radius, int rings, int slices);
uint LoadPlane(const string &in key, float width, float length, int resX, int resZ);
uint LoadCylinder(const string &in key, float radius, float height, int slices);
uint LoadCone(const string &in key, float radius, float height, int slices);
uint LoadTorus(const string &in key, float radius, float size, int radSeg, int sides);
uint LoadKnot(const string &in key, float radius, float size, int radSeg, int sides);
uint LoadHeightmap(const string &in key, const string &in heightmapPath, float sizeX, float sizeY, float sizeZ);
uint LoadCubicmap(const string &in key, const string &in cubicmapPath, float sizeX, float sizeY, float sizeZ);
uint CreateMaterial(const string &in key, uint shaderId, uint8 r, uint8 g, uint8 b, uint8 a);
bool UnloadTexture(const string &in key);
bool UnloadShader(const string &in key);
bool UnloadModel(const string &in key);
bool UnloadMaterial(const string &in key);
uint GetTextureId(const string &in key);
uint GetShaderId(const string &in key);
uint GetModelId(const string &in key);
uint GetMaterialId(const string &in key);
bool ApplyMeshTangents(const string &in key, int meshIndex = 0);
}
namespace Scene {
uint Load(const string &in path, bool clearExisting = true);
void Clear();
}
namespace Texture {
class Image {
int width;
int height;
int mipmaps;
int format;
};
Image@ LoadImage(const string&in path);
void Unload(const Image@&in image);
class Texture2D {
int id;
int width;
int height;
int mipmaps;
int format;
};
Texture2D@ LoadTexture(const string&in path);
Texture2D@ LoadFromImage(const Image@&in image);
void Draw(const Texture2D@&in texture, int x, int y, int color);
void Unload(const Texture2D@&in texture);
}
namespace Math {
float Sin(float angle);
float Cos(float angle);
float Tan(float angle);
float ASin(float value);
float ACos(float value);
float ATan(float value);
float ATan2(float y, float x);
float Sqrt(float value);
float Pow(float base, float exponent);
float Log(float value);
float Log10(float value);
float Exp(float exponent);
float Floor(float value);
float Ceil(float value);
float Modf(float x, float y);
float Abs(float value);
}
// Raylib input and timing functions
float GetTime();
bool IsKeyPressed(int key);
// Input Action System
bool IsActionPressed(const string &in actionName);
bool IsActionDown(const string &in actionName);
bool IsActionReleased(const string &in actionName);
float GetActionStrength(const string &in actionName);
void RegisterAction(const string &in actionName);
void BindKeyboard(const string &in actionName, int keyCode);
void BindMouseButton(const string &in actionName, int mouseButton);
void BindGamepadButton(const string &in actionName, int gamepadId, int button);
void BindGamepadAxis(const string &in actionName, int gamepadId, int axis, float threshold = 0.5f, bool negative = false);
void ClearBindings(const string &in actionName);
void ClearAllActions();
namespace Key {
const int SPACE = 32;
const int ESCAPE = 256;
const int ENTER = 257;
const int TAB = 258;
const int BACKSPACE = 259;
const int RIGHT = 262;
const int LEFT = 263;
const int DOWN = 264;
const int UP = 265;
const int W = 87;
const int A = 65;
const int S = 83;
const int D = 68;
const int E = 69;
const int LEFT_CONTROL = 341;
}
namespace MouseButton {
const int LEFT = 0;
const int RIGHT = 1;
const int MIDDLE = 2;
}
// Key-value store (SNKV)
namespace KV {
uint Open(const string &in name);
bool Close(uint handle);
bool Put(uint handle, const string &in key, const string &in value);
bool Put(uint handle, const string &in key, int value);
bool Put(uint handle, const string &in key, uint value);
bool Put(uint handle, const string &in key, int64 value);
bool Put(uint handle, const string &in key, float value);
bool Put(uint handle, const string &in key, double value);
bool Put(uint handle, const string &in key, bool value);
bool Put(uint handle, const string &in key, const array<uint8> &in value);
bool PutTtl(uint handle, const string &in key, const string &in value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, int value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, uint value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, int64 value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, float value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, double value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, bool value, int64 ttlMs);
bool PutTtl(uint handle, const string &in key, const array<uint8> &in value, int64 ttlMs);
bool Get(uint handle, const string &in key, string &out value);
bool Get(uint handle, const string &in key, int &out value);
bool Get(uint handle, const string &in key, uint &out value);
bool Get(uint handle, const string &in key, int64 &out value);
bool Get(uint handle, const string &in key, float &out value);
bool Get(uint handle, const string &in key, double &out value);
bool Get(uint handle, const string &in key, bool &out value);
bool Get(uint handle, const string &in key, array<uint8> &out value);
bool GetTtl(uint handle, const string &in key, string &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, int &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, uint &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, int64 &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, float &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, double &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, bool &out value, int64 &out remainingMs);
bool GetTtl(uint handle, const string &in key, array<uint8> &out value, int64 &out remainingMs);
bool Delete(uint handle, const string &in key);
bool Exists(uint handle, const string &in key);
bool TtlRemaining(uint handle, const string &in key, int64 &out remainingMs);
int PurgeExpired(uint handle);
}
// In-memory globals (cross-scene, not persisted)
namespace Globals {
bool Set(const string &in key, const string &in value);
bool Set(const string &in key, int value);
bool Set(const string &in key, uint value);
bool Set(const string &in key, int64 value);
bool Set(const string &in key, float value);
bool Set(const string &in key, double value);
bool Set(const string &in key, bool value);
bool Set(const string &in key, const array<uint8> &in value);
bool Get(const string &in key, string &out value);
bool Get(const string &in key, int &out value);
bool Get(const string &in key, uint &out value);
bool Get(const string &in key, int64 &out value);
bool Get(const string &in key, float &out value);
bool Get(const string &in key, double &out value);
bool Get(const string &in key, bool &out value);
bool Get(const string &in key, array<uint8> &out value);
bool Has(const string &in key);
bool Remove(const string &in key);
}
namespace GamepadButton {
const int UNKNOWN = 0;
const int LEFT_FACE_UP = 1;
const int LEFT_FACE_RIGHT = 2;
const int LEFT_FACE_DOWN = 3;
const int LEFT_FACE_LEFT = 4;
const int RIGHT_FACE_UP = 5;
const int RIGHT_FACE_RIGHT = 6;
const int RIGHT_FACE_DOWN = 7;
const int RIGHT_FACE_LEFT = 8;
const int LEFT_TRIGGER_1 = 9;
const int LEFT_TRIGGER_2 = 10;
const int RIGHT_TRIGGER_1 = 11;
const int RIGHT_TRIGGER_2 = 12;
const int MIDDLE_LEFT = 13;
const int MIDDLE = 14;
const int MIDDLE_RIGHT = 15;
const int LEFT_THUMB = 16;
const int RIGHT_THUMB = 17;
}
namespace GamepadAxis {
const int LEFT_X = 0;
const int LEFT_Y = 1;
const int RIGHT_X = 2;
const int RIGHT_Y = 3;
const int LEFT_TRIGGER = 4;
const int RIGHT_TRIGGER = 5;
}