Files
Basalt/docs/objects/Program/setEnviroment.md
Robert Jelic bb1b1beb79 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
2023-04-30 17:05:34 +02:00

1002 B

setEnviroment

Description

Changes the default environment to a custom environment

Parameters

  1. table - Enviroment table

Returns

  1. object object in use

Usage

  • Set a custom environment for a program:
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.