Getting Started
This guide will help you install SIMPLOO and create your first class.
Installation
- Download
simploo.luafrom the releases page or build it from source - Place the file in your project directory
- Load it at the start of your program:
Or if you're using require:
Your First Class
Let's create a simple Counter class that can increment and display a value.
Creating Instances
Once a class is defined, create instances using .new():
local myCounter = Counter.new()
myCounter:increment()
myCounter:increment()
myCounter:increment()
myCounter:print() -- Count: 3
Each instance has its own copy of the class members:
local counter1 = Counter.new()
local counter2 = Counter.new()
counter1:increment()
counter1:increment()
counter1:print() -- Count: 2
counter2:print() -- Count: 0
Adding a Constructor
Use __construct to initialize instances with custom values:
Now you can pass arguments when creating instances:
Development vs Production Mode
SIMPLOO has two modes:
- Development mode (default) - Includes safety checks like private member access enforcement
- Production mode - Disables checks for better performance
Set the mode before loading simploo:
See Configuration for all available options.
Next Steps
- Classes - Learn both syntax styles in detail
- Members - Variables and methods
- Constructors - Initialization and cleanup
- Modifiers - Add
private,static, and more