Files
Basalt/docs/objects/Program.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

1.8 KiB

Program objects allow you to execute other programs within your main application. You can run programs such as worms, shell, or any custom programs you've created. This object also has two unique events: onError and onDone.

In addition to the Object and VisualObject methods, lists also have the following methods:

getStatus Returns the current program status
execute Executes a program
stop Stops the currently running program
pause Pauses the currently running program
isPaused Returns if the program is paused
injectEvent Injects an event into the program
injectEvents Injects a table of events
getQueuedEvents Returns currently queued events
setEnviroment Changes the default environment to a custom one

Events

This is a list of all available events for programs:

onError Fires when a program encounters an error
onDone Fires when a program has finished executing

Here's an example of how to create a Program object, execute a program, and handle events:

Lua:

local mainFrame = basalt.createFrame()
local aProgram = mainFrame:addProgram()

aProgram:onError(function(self, event, err)
  basalt.log("An error occurred: " .. err)
end)

aProgram:onDone(function()
  basalt.debug("Program finished successfully")
end)

aProgram:execute("path/to/your/program.lua")

This example demonstrates how to create a Program object, execute a program located at "path/to/your/program", and handle the onError and onDone events.