Skip to content

Commit 797a48e

Browse files
authored
Update Basalt.md
1 parent ccdebe3 commit 797a48e

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

docs/objects/Basalt.md

+30-25
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ To start using Basalt you have to do the following line of code:
44

55
remember you need the basalt.lua file on your computer!
66

7-
Now you are able to call all these functions:
7+
Now you are able to use the following functions:
88

99
## basalt.createFrame
10-
Create a frame without a parent
10+
Create a base-frame (main frame)
1111
#### Parameters:
1212
1. `string` name
1313

@@ -21,7 +21,7 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
2121
```
2222

2323
## basalt.removeFrame
24-
Removes a frame (only possible for non-parent frames)
24+
Removes a base frame
2525

2626
#### Parameters:
2727
1. `string` name
@@ -34,7 +34,7 @@ basalt.removeFrame("myFirstFrame")
3434
```
3535

3636
## basalt.getFrame
37-
With that function you can get frames, but only frames without a parent!
37+
Returns a base frame with the given name
3838
#### Parameters:
3939
1. `string` name
4040

@@ -50,7 +50,7 @@ basalt.getFrame("myFirstFrame"):show()
5050

5151

5252
## basalt.getActiveFrame
53-
Returns the currently active (without a parent) frame
53+
Returns the currently active base frame
5454

5555
#### Returns:
5656
1. `frame` The current frame
@@ -74,50 +74,55 @@ basalt.autoUpdate()
7474

7575

7676
## basalt.update
77-
Calls the draw and event handler method once
77+
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.
7878

7979
#### Parameters:
8080
1. `string` The event to be received
8181
2. `...` Additional event variables to capture
8282

8383
#### Usage:
84-
* Prints "Left Mouse Button clicked!" when clicked
84+
* Creates and starts a custom update cycle
8585
```lua
86-
quitButton:onClick(
87-
function(obj, event, x, y)
88-
if(event == "mouse_click") and (button == 1) then --> The button at index 1 is left
89-
basalt.debug("Left Mouse Button clicked!")
90-
end
91-
end
92-
)
86+
local mainFrame = basalt.createFrame("myFirstFrame"):show()
87+
local aButton = mainFrame:addButton("myButton"):setPosition(2,2):show()
88+
89+
while true do
90+
basalt.update(os.pullEventRaw())
91+
end
9392
```
9493

9594
## basalt.stopUpdate
96-
Stops the draw and event handler _(including, but not limited to mouse clicks)_
95+
Stops the automatic draw and event handler which got started by basalt.autoUpdate()
9796

9897
#### Usage:
9998
* When the quit button is clicked, the button stops basalt updates and clears the terminal
10099
```lua
101-
quitButton:onClick(
102-
function(obj, event)
103-
if (event == "mouse_click") and (obj == quitButton) then --> The button at index 1 is left
104-
basalt.stopUpdate()
105-
term.clear()
106-
end
107-
end
108-
)
100+
```lua
101+
local mainFrame = basalt.createFrame("myFirstFrame"):show()
102+
local aButton = mainFrame:addButton("myButton"):setPosition(2,2):setText("Stop Basalt!"):show()
103+
104+
aButton:onClick(function()
105+
basalt.stopUpdate()
106+
end)
107+
108+
basalt.autoUpdate()
109109
```
110110

111111

112112
## basalt.debug
113-
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
113+
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
114+
115+
You can also edit the default debug Label (change position, change color or whatever you want) by accessing the variable basalt.debugLabel
116+
which returns the debug Label.
117+
118+
Also basalt.debugFrame and basalt.debugList are available.
114119

115120
#### Parameters:
116121
1. `...` (multiple parameters are possible, like print does)<br>
117122

118123
#### Usage:
119124
* Prints "Hello! ^-^" to the debug console
120125
```lua
121-
basalt.debug("Hello! ^-^")
126+
basalt.debug("Hello! ", "^-^")
122127
```
123128

0 commit comments

Comments
 (0)