Skip to content

Getting Started

Samuel Pizette edited this page May 19, 2022 · 4 revisions

You want to know how to use basalt for your projects? Easy! Just use the following command in your computercraft computer/turtle/pocket comp. shell:

pastebin run ESs1mg7P

After this is done, edit your program and add the following line on top of your program:

local basalt = dofile("basalt.lua")

now you are able to access everything you need from basalt.

but how do you actually start? Here is a simple example of how you would create a simple button on the screen:

--Here you load the basalt framework into your file:
local basalt = dofile("basalt.lua")

--Here you create a non-parent frame. The basalt.update/autoUpdate events will always give their events to a non-parent frame! Which means you always need atleast one active non-parent frame!
--As variable you have to use a unique name - otherwise you wont get a frame object back. :show() immediatly shows the object on the screen
local main = basalt.createFrame("mainFrame")
main:show() -- now we make the main frame visible

local button = main:addButton("clickableButton") -- here we add a button to the main frame (with a unique name)
button:setPosition(4,4) -- here we just change the position of that button (default position would be 1, 1)
button:setText("Click me!") -- we set the text of that button 
local function buttonClick() -- we create a function which the button should call if we click on that button
basalt.debug("I got clicked!") 
end
button:onClick(buttonClick) -- here we add a onClick event and add the created function to the list
button:show() -- ofc it also has to be visible

--Here you start the event listener.
basalt.autoUpdate()

You dont like the amount of lines you need for that? No problem, this does 1-1 the same thing as above:

local basalt = dofile("basalt.lua")

local main = basalt.createFrame("mainFrame"):show()
local button = main:addButton("clickableButton"):setPosition(4,4):setText("Click me!"):onClick(function() basalt.debug("I got clicked!") end):show()

basalt.autoUpdate()

Wiki Navigation

Home
Clone this wiki locally