Skip to content

Commit

Permalink
Update Basalt.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NoryiE committed Jun 25, 2022
1 parent ccdebe3 commit 797a48e
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions docs/objects/Basalt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Now you are able to call all these functions:
Now you are able to use the following functions:

## basalt.createFrame
Create a frame without a parent
Create a base-frame (main frame)
#### Parameters:
1. `string` name

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

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

#### Parameters:
1. `string` name
Expand All @@ -34,7 +34,7 @@ basalt.removeFrame("myFirstFrame")
```

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

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


## basalt.getActiveFrame
Returns the currently active (without a parent) frame
Returns the currently active base frame

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


## 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:
1. `string` The event to be received
2. `...` Additional event variables to capture

#### Usage:
* Prints "Left Mouse Button clicked!" when clicked
* Creates and starts a custom update cycle
```lua
quitButton:onClick(
function(obj, event, x, y)
if(event == "mouse_click") and (button == 1) then --> The button at index 1 is left
basalt.debug("Left Mouse Button clicked!")
end
end
)
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myButton"):setPosition(2,2):show()

while true do
basalt.update(os.pullEventRaw())
end
```

## 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:
* When the quit button is clicked, the button stops basalt updates and clears the terminal
```lua
quitButton:onClick(
function(obj, event)
if (event == "mouse_click") and (obj == quitButton) then --> The button at index 1 is left
basalt.stopUpdate()
term.clear()
end
end
)
```lua
local mainFrame = basalt.createFrame("myFirstFrame"):show()
local aButton = mainFrame:addButton("myButton"):setPosition(2,2):setText("Stop Basalt!"):show()

aButton:onClick(function()
basalt.stopUpdate()
end)

basalt.autoUpdate()
```


## 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:
1. `...` (multiple parameters are possible, like print does)<br>

#### Usage:
* Prints "Hello! ^-^" to the debug console
```lua
basalt.debug("Hello! ^-^")
basalt.debug("Hello! ", "^-^")
```

0 comments on commit 797a48e

Please sign in to comment.