13 KiB
13 KiB
The Rhai Scripting Language
User’s Guide
Rust Integration
- Introduction
- Traits
- Register a Rust Function
- Call a Rhai Function from Rust
- Operator Overloading
- Working with Any Rust Type
- Modules
- Plugin Modules
- Packages
Scripting Language
- Comments
- Values and Types
- Keywords
- Statements
- Variables
- Constants
- Assignments
- Compound Assignments
- Logic Operators
- In Operator
- If Statement
- Switch Statement
- While Loop
- Do Loop
- Loop Statement
- For Loop
- Return Value
- Throw Exception on Error
- Catch Exceptions
- Functions
- Print and Debug
- Modules
- Eval Function
Safety and Protection
- Introduction
- Sand-Boxing
- Limiting Run Time
- Limiting Memory Usage
- Limiting Stack Usage
- Built-in Safety Limits
- Turn Off Safety Checks
Script Optimization
Advanced Topics
- Manage AST's
- Low-Level API to Register Functions
- Evaluation Context
- Call Function Within Caller's Scope
- Use Rhai in Dynamic Libraries
- Use Rhai as a DSL
- Debugging Interface
Usage Patterns
- Object-Oriented Programming (OOP)
- Scriptable Event Handler with State
- Control Layer Over Rust Backend
- Singleton Command Object
- Loadable Configuration
- Multi-Layered Functions
- Hot Reloading
- Builder Pattern / Fluent API
- Objects with Defined Behaviors
- Dynamic Constants Provider
- Global Constants
- Mutable Global State
- Working with Rust Enums
- Simulate Macros to Simplify Scripts
- One Engine Instance Per Call
- Multi-Threaded Synchronization
- Blocking/Async Function Calls
- External References (Unsafe)
- Static Hashing
- Serialize an AST
- Domain-Specific Tools
- Multiple Instantiation
Language Reference
- Introduction
- Comments
- Value Types
- Keywords
- Statements
- Variables
- Constants
- Assignments
- Operators
- Indexing
- Properties
- Methods
- If Statement
- Switch Statement
- While Loop
- Do Loop
- Infinite Loop
- For Loop
- Return Value
- Throw Exception on Error
- Functions
- Print and Debug
- Modules
- Eval Function