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
This commit is contained in:
@@ -1,48 +1,47 @@
|
||||
# How-To
|
||||
|
||||
After downloading the project you can finally start creating your own program and use basalt. The first thing you want to use in your program is always:
|
||||
After downloading the project, you can start creating your own program and use Basalt. The first thing you want to include in your program is always:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
It doesn't matter if you're using the source folder or the minified/packed version of basalt. Both can be found by using require("basalt") without .lua.
|
||||
It doesn't matter if you're using the source folder or the minified/packed version of Basalt. Both can be found by using require("basalt") without .lua.
|
||||
|
||||
Also to really run basalt you should use
|
||||
To run Basalt, you should use:
|
||||
|
||||
```lua
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
somewhere on the bottom of your program. basalt.autoUpdate() starts the event listener and the draw handler.
|
||||
This should be placed at the bottom of your program. basalt.autoUpdate() starts the event listener and the draw handler.
|
||||
|
||||
## Example
|
||||
|
||||
Here is a fully working example of how a program could look like:
|
||||
Here's a fully working example of how a program could look like:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") --> Load the basalt framework into the variable called "basalt"
|
||||
local basalt = require("basalt") --> Load the Basalt framework into the variable called "basalt"
|
||||
|
||||
--> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show())
|
||||
local main = basalt.createFrame()
|
||||
|
||||
local button = main:addButton() --> Here we add our first button
|
||||
button:setPosition(4, 4) -- of course we want to change the default position of our button
|
||||
button:setSize(16, 3) -- and the default size.
|
||||
button:setText("Click me!") --> This method displays what the text of our button should look like
|
||||
button:setPosition(4, 4) -- We want to change the default position of our button
|
||||
button:setSize(16, 3) -- And the default size.
|
||||
button:setText("Click me!") --> This method sets the text displayed on our button
|
||||
|
||||
local function buttonClick() --> Let us create a function we want to call when the button gets clicked
|
||||
local function buttonClick() --> Create a function we want to call when the button gets clicked
|
||||
basalt.debug("I got clicked!")
|
||||
end
|
||||
|
||||
-- Now we just need to register the function to the buttons onClick event handlers, this is how we can achieve that:
|
||||
-- Now we just need to register the function to the button's onClick event handlers, this is how we can achieve that:
|
||||
button:onClick(buttonClick)
|
||||
|
||||
|
||||
basalt.autoUpdate() -- As soon as we call basalt.autoUpdate, the event and draw handlers will listen to any incomming events (and draw if necessary)
|
||||
basalt.autoUpdate() -- As soon as we call basalt.autoUpdate, the event and draw handlers will listen to any incoming events (and draw if necessary)
|
||||
```
|
||||
|
||||
If you're like us and strive for succinct and beautiful code, here is a cleaner implementation of the code above:
|
||||
If you strive for succinct and beautiful code, here's a cleaner implementation of the code above:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
@@ -50,11 +49,11 @@ local basalt = require("basalt")
|
||||
local main = basalt.createFrame()
|
||||
local button = main --> Basalt returns an instance of the object on most methods, to make use of "call-chaining"
|
||||
:addButton() --> This is an example of call chaining
|
||||
:setPosition(4,4)
|
||||
:setPosition(4, 4)
|
||||
:setText("Click me!")
|
||||
:onClick(
|
||||
function()
|
||||
basalt.debug("I got clicked!")
|
||||
function()
|
||||
basalt.debug("I got clicked!")
|
||||
end)
|
||||
|
||||
basalt.autoUpdate()
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
Basalt provides multiple unique versions. A source version, a minified version and a web version.
|
||||
Basalt offers three unique versions for different use cases: a Source version, a Minified/Packed version, and a Web version.
|
||||
|
||||
## Source
|
||||
## Source Version
|
||||
|
||||
This version is, like the name already says, the source code of basalt. If you want to dig into the code, add additional content or just prefer to use the source, then you should aim for the source-version.
|
||||
The Source version, as the name suggests, contains the unmodified source code of Basalt. Use this version if you want to explore the code, add custom content, or prefer working with the original source.
|
||||
|
||||
The following command allows you to download the source-version on your computer:
|
||||
To download the Source version, use the following command:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua source [foldername] [branch]`
|
||||
|
||||
The first optional argument is the folder name you wish that basalt should be installed into, by default the folder is called basalt.
|
||||
The second optional argument is the branch you want to use. If you don't know what this means please ignore it (the 2 options are master and dev)
|
||||
- `foldername` (optional): The folder name for the Basalt installation (default: `basalt`).
|
||||
- `branch` (optional): Choose between `master` and `dev` branches (default: `master`).
|
||||
|
||||
## Minified / Packed
|
||||
## Minified/Packed Version
|
||||
|
||||
This version is the minified version, i also call it the packed version. There are 2 changes, the first one is that the code will be shown minified which makes the size much smaller, the second change is that you will recieve a file instead of a folder.
|
||||
The Minified/Packed version is a compressed version of the Basalt code. It reduces the file size and combines the code into a single file instead of a folder, making it easier to manage.
|
||||
|
||||
The following command allows you to download the packed-version on your computer:
|
||||
To download the Minified/Packed version, use the following command:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua packed [filename] [branch]`
|
||||
|
||||
The first optional argument is the file name you wish that the installer should use, by default the file is called basalt.lua.
|
||||
The second optional argument is the branch you want to use. If you don't know what this means please ignore it (the 2 options are master and dev)
|
||||
- `filename` (optional): The file name for the Basalt installation (default: `basalt.lua`).
|
||||
- `branch` (optional): Choose between `master` and `dev` branches (default: `master`).
|
||||
|
||||
## Web
|
||||
## Web Version
|
||||
|
||||
The web version is a special version, used if your goal is to keep your project's size as small as possible. I suggest you to use the web version only if you don't restart your program over and over again. For example if you designed your program to reboot after the user made a bad choice (leads into a error or something like that) it is better to use the minified/source version.
|
||||
The Web version is designed for minimal project size and fetches the required code from the web when needed. This version is recommended for projects that don't require frequent restarts. If your program reboots often due to user input or errors, it's better to use the Source or Minified versions.
|
||||
|
||||
The following command allows you to download the web-version on your computer:
|
||||
To download the Web version, use the following command:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua web [version] [filename]`
|
||||
|
||||
By default the first argument is the latest version of basalt's releases. [Here](https://github.com/Pyroxenium/Basalt/tree/master/docs/versions) you can see which versions are available to use.
|
||||
For example: wget run https://basalt.madefor.cc/install.lua web basalt-1.6.3.lua - the second argument is just the file name, default is basaltWeb.lua.
|
||||
- `version` (optional): Specify the desired version of Basalt (default: latest version). [Click here](https://github.com/Pyroxenium/Basalt/tree/master/docs/versions) to see the available versions.
|
||||
- `filename` (optional): The file name for the Basalt installation (default: `basaltWeb.lua`).
|
||||
|
||||
Remember to rename `local basalt = require("basalt")` into `local basalt = require("basaltWeb")` if you want to use the web-version
|
||||
**Note**: If using the Web version, remember to change `local basalt = require("basalt")` to `local basalt = require("basaltWeb")` in your code.
|
||||
59
docs/home/getting-started.md
Normal file
59
docs/home/getting-started.md
Normal file
@@ -0,0 +1,59 @@
|
||||
After downloading the project, you can finally start creating your own program and using Basalt. The first thing you will want to use in your program is always:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
It doesn't matter if you are using the source folder or the minified/packed version of Basalt. Both can be found using require("basalt") without the .lua extension.
|
||||
|
||||
To actually start using Basalt, you should include the following line at the bottom of your program:
|
||||
|
||||
```lua
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
This will start the event listener and the draw handler.
|
||||
|
||||
## Example
|
||||
|
||||
Here is a fully functional example of how a program could look:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") --> Load the Basalt framework into the variable "basalt"
|
||||
|
||||
--> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible (you don't need to use :show())
|
||||
local main = basalt.createFrame()
|
||||
|
||||
local button = mainFrame:addButton() --> Here we add our first button
|
||||
button:setPosition(4, 4) -- Of course we want to change the default position of our button
|
||||
button:setSize(16, 3) -- And the default size.
|
||||
button:setText("Click me!") --> This method displays what the text of our button should look like
|
||||
|
||||
local function buttonClick() --> Let us create a function we want to call when the button gets clicked
|
||||
basalt.debug("I got clicked!")
|
||||
end
|
||||
|
||||
-- Now we just need to register the function to the button's onClick event handlers, this is how we can achieve that:
|
||||
button:onClick(buttonClick)
|
||||
|
||||
|
||||
basalt.autoUpdate() -- As soon as we call basalt.autoUpdate, the event and draw handlers will listen for any incoming events (and draw if necessary)
|
||||
```
|
||||
|
||||
If you're like us and strive for succinct and beautiful code, here is a cleaner implementation of the code above:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local button = main --> Basalt returns an instance of the object on most methods, to make use of "call-chaining"
|
||||
:addButton() --> This is an example of call chaining
|
||||
:setPosition(4,4)
|
||||
:setText("Click me!")
|
||||
:onClick(
|
||||
function()
|
||||
basalt.debug("I got clicked!")
|
||||
end)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
Reference in New Issue
Block a user