Basalt 1.7 Update
- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
This commit is contained in:
@@ -1,10 +1,38 @@
|
||||
## setEnviroment
|
||||
Changes the default enviroment to a custom enviroment
|
||||
|
||||
#### Parameters:
|
||||
### Description
|
||||
|
||||
Changes the default environment to a custom environment
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `table` - Enviroment table
|
||||
|
||||
#### Returns:
|
||||
### Returns
|
||||
|
||||
1. `program` Program in use
|
||||
1. `object` object in use
|
||||
|
||||
### Usage
|
||||
|
||||
* Set a custom environment for a program:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aProgram = mainFrame:addProgram()
|
||||
|
||||
local customEnvironment = {
|
||||
print = function(...)
|
||||
local args = {...}
|
||||
basalt.debug("Custom print:", unpack(args))
|
||||
end
|
||||
}
|
||||
|
||||
aProgram:setEnvironment(customEnvironment) -- Set the custom environment
|
||||
aProgram:execute(function()
|
||||
print("Hello, World!")
|
||||
end)
|
||||
```
|
||||
|
||||
In this example, a Program object is created and added to the mainFrame. A custom environment table is created with a custom `print` function. The custom environment is then set for the program using the `setEnvironment` method. When the program is executed, it will use the custom `print` function from the custom environment instead of the default print function.
|
||||
|
||||
Reference in New Issue
Block a user