Accidentally uploaded outdated 1.6 docs
This commit is contained in:
Robert Jelic
2023-05-01 16:28:46 +02:00
parent 92b93a3862
commit d4c72514ef
265 changed files with 25608 additions and 3867 deletions

View File

@@ -0,0 +1,19 @@
## execute
Executes the given path or program
#### Parameters:
1. `string|function` the path to your file as string, or function which should be called
#### Returns:
1. `object` The object in use
#### Usage:
* Executes worm
```lua
local mainFrame = basalt.createFrame()
local aProgram = mainFrame:addProgram()
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
```
```xml
<program path="rom/programs/fun/worm.lua" execute="true" />
```

View File

@@ -0,0 +1,34 @@
## getQueuedEvents
If the program is paused, incomming events will be inserted into a queued events table. As soon as the program is unpaused, the queued events table will be empty
#### Returns:
1. `table` a table - {event="event", args={"a", "b",...}}
#### Usage:
* prints the queued events table
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
mainFrame:addButton():setText("inject"):onClick(function() basalt.debug(aProgram:getQueuedEvents()) end):show()
```
## updateQueuedEvents
Here you can manipulate the queued events table
#### Parameters:
1. `table` a table, items should be {event="event", args={para1, para2, para3, para4}}
#### Returns:
1. `object` The object in use
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
mainFrame:addButton():setText("inject"):onClick(function()
local events = aProgram:getQueuedEvents()
table.insert(events,1,{event="char", args={"w"}}
aProgram:updateQueuedEvents(events)
end):show()
```

View File

@@ -0,0 +1,13 @@
## getStatus
returns the current process status
#### Returns:
1. `string` current status ("running", "normal, "suspended", or "dead")
#### Usage:
* Prints current status
```lua
local mainFrame = basalt.createFrame()
local aProgram = mainFrame:addProgram()
basalt.debug(aProgram:getStatus())
```

View File

@@ -0,0 +1,21 @@
## injectEvent
injects a event into the program manually. For example you could inject w a s and d for worm, by clicking buttons.
#### Parameters:
1. `string` event
2. `any` parameter
3. `any` parameter
4. `any` parameter
5. `any` parameter
6. `boolean` if this is true, the injected event will be executed even if the program is paused
#### Returns:
1. `object` The object in use
#### Usage:
* injects a event by clicking a button
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
mainFrame:addButton():setText("inject"):onClick(function() aProgram:injectEvent("char", "w") end):show()
```

View File

@@ -0,0 +1,23 @@
## injectEvents
Injects multiple events
#### Parameters:
1. `table` a table, items should be {event="event", args={para1, para2, para3, para4}}
#### Returns:
1. `object` The object in use
#### Usage:
* injects a multiple char events by clicking a button
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
local events = {
{event="char", args={"h"}},
{event="char", args={"e"}},
{event="char", args={"y"}}
}
mainFrame:addButton():setText("inject"):onClick(function() aProgram:injectEvents(events) end):show()
```

View File

@@ -0,0 +1,13 @@
## isPaused
returns if the program is paused
#### Returns:
1. `boolean` pause status
#### Usage:
* Prints the pause status of the program
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
basalt.debug(aProgram:isPaused())
```

View File

@@ -0,0 +1,19 @@
# onDone
`onDone(self, err)`<br>
This is a custom event which gets triggered as soon as the program has finished.
Here is a example on how to add a onDone event to your program:
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local aProgram = main:addProgram():execute("rom/programs/shell.lua")
local function onProgramDone()
basalt.debug("Program has finished")
end
aProgram:onDone(onProgramDone)
```

View File

@@ -0,0 +1,34 @@
# onError
`onError(self, err)`<br>
This is a custom event which gets triggered as soon as the program catched a error.
Here is a example on how to add a onError event to your program:
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local aProgram = main:addProgram():execute("rom/programs/shell.lua")
local function onProgramError(self, err)
local errFrame = main:addFrame()
:setSize(30, 10)
:setPosition("parent.w / 2 - self.w / 2", "parent.h / 2 - self.h / 2")
errFrame:addLabel()
:setPosition(2, 3)
:setSize("parent.w - 2", "parent.h - 3")
:setText(err)
errFrame:addButton()
:setPosition("parent.w", 1)
:setSize(1, 1)
:setText("X")
:onClick(function()
errFrame:remove()
end)
end
aProgram:onError(onProgramError)
```

View File

@@ -0,0 +1,16 @@
## pause
pauses the current program (prevents the program from receiving events)
#### Parameters:
1. `boolean` true, false or nothing
#### Returns:
1. `object` The object in use
#### Usage:
* Pauses worm by clicking a button
```lua
local mainFrame = basalt.createFrame():show()
local aProgram = mainFrame:addProgram():execute("rom/programs/shell.lua"):show()
mainFrame:addButton():setText("Pause"):onClick(function() aProgram:pause(true) end):show()
```

View File

@@ -0,0 +1,10 @@
## setEnviroment
Changes the default enviroment to a custom enviroment
#### Parameters:
1. `table` - Enviroment table
#### Returns:
1. `program` Program in use

View File

@@ -0,0 +1,14 @@
## stop
Stops a currently running program
#### Returns:
1. `object` The object in use
#### Usage:
* Stops worm by clicking a button
```lua
local mainFrame = basalt.createFrame()
local aProgram = mainFrame:addProgram()
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
mainFrame:addButton():setText("Pause"):onClick(function() aProgram:stop() end):show()
```