Update Basalt.md

This commit is contained in:
Robert Jelic
2022-06-25 15:57:14 +02:00
committed by GitHub
parent ccdebe30ef
commit 797a48ea95

View File

@@ -4,10 +4,10 @@ To start using Basalt you have to do the following line of code:
remember you need the basalt.lua file on your computer! remember you need the basalt.lua file on your computer!
Now you are able to call all these functions: Now you are able to use the following functions:
## basalt.createFrame ## basalt.createFrame
Create a frame without a parent Create a base-frame (main frame)
#### Parameters: #### Parameters:
1. `string` name 1. `string` name
@@ -21,7 +21,7 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
``` ```
## basalt.removeFrame ## basalt.removeFrame
Removes a frame (only possible for non-parent frames) Removes a base frame
#### Parameters: #### Parameters:
1. `string` name 1. `string` name
@@ -34,7 +34,7 @@ basalt.removeFrame("myFirstFrame")
``` ```
## basalt.getFrame ## basalt.getFrame
With that function you can get frames, but only frames without a parent! Returns a base frame with the given name
#### Parameters: #### Parameters:
1. `string` name 1. `string` name
@@ -50,7 +50,7 @@ basalt.getFrame("myFirstFrame"):show()
## basalt.getActiveFrame ## basalt.getActiveFrame
Returns the currently active (without a parent) frame Returns the currently active base frame
#### Returns: #### Returns:
1. `frame` The current frame 1. `frame` The current frame
@@ -74,43 +74,48 @@ basalt.autoUpdate()
## basalt.update ## basalt.update
Calls the draw and event handler method once Calls the draw and event handler once - this gives more flexibility about which events basalt should process. For example you could filter the terminate event.
#### Parameters: #### Parameters:
1. `string` The event to be received 1. `string` The event to be received
2. `...` Additional event variables to capture 2. `...` Additional event variables to capture
#### Usage: #### Usage:
* Prints "Left Mouse Button clicked!" when clicked * Creates and starts a custom update cycle
```lua ```lua
quitButton:onClick( local mainFrame = basalt.createFrame("myFirstFrame"):show()
function(obj, event, x, y) local aButton = mainFrame:addButton("myButton"):setPosition(2,2):show()
if(event == "mouse_click") and (button == 1) then --> The button at index 1 is left
basalt.debug("Left Mouse Button clicked!") while true do
end basalt.update(os.pullEventRaw())
end end
)
``` ```
## basalt.stopUpdate ## basalt.stopUpdate
Stops the draw and event handler _(including, but not limited to mouse clicks)_ Stops the automatic draw and event handler which got started by basalt.autoUpdate()
#### Usage: #### Usage:
* When the quit button is clicked, the button stops basalt updates and clears the terminal * When the quit button is clicked, the button stops basalt updates and clears the terminal
```lua ```lua
quitButton:onClick( ```lua
function(obj, event) local mainFrame = basalt.createFrame("myFirstFrame"):show()
if (event == "mouse_click") and (obj == quitButton) then --> The button at index 1 is left local aButton = mainFrame:addButton("myButton"):setPosition(2,2):setText("Stop Basalt!"):show()
basalt.stopUpdate()
term.clear() aButton:onClick(function()
end basalt.stopUpdate()
end end)
)
basalt.autoUpdate()
``` ```
## basalt.debug ## basalt.debug
creates a label with some information on the main frame on the bottom left, if you click on that label it will open a log view for you see it as the new print for debugging creates a label with some information on the main frame on the bottom left, if you click on that label it will open a log view for you. See it as the new print for debugging
You can also edit the default debug Label (change position, change color or whatever you want) by accessing the variable basalt.debugLabel
which returns the debug Label.
Also basalt.debugFrame and basalt.debugList are available.
#### Parameters: #### Parameters:
1. `...` (multiple parameters are possible, like print does)<br> 1. `...` (multiple parameters are possible, like print does)<br>
@@ -118,6 +123,6 @@ creates a label with some information on the main frame on the bottom left, if y
#### Usage: #### Usage:
* Prints "Hello! ^-^" to the debug console * Prints "Hello! ^-^" to the debug console
```lua ```lua
basalt.debug("Hello! ^-^") basalt.debug("Hello! ", "^-^")
``` ```