Updated How To (markdown)

Robert Jelic
2022-05-05 19:12:37 +02:00
parent 024d9dca09
commit a73c7c7725

@@ -6,4 +6,37 @@ After you did this, edit your program and add the following line on top of your
`local basalt = dofile("basalt.lua")`
now you are able to access everything you need from basalt.
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:
````lua
--Here you load the basalt framework into your file:
local basalt = dofile("basalt.lua")
--Here you create a level0 frame (a frame without a parents) only frames can be shown without a parent.
--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"):show()
main:show()
local button = main:addButton("clickableButton")
button:setPosition(4,4)
button:setText("Click me!")
local function buttonClick()
basalt.debug("I got clicked!")
end
button:onClick(buttonClick)
button:show()
basalt.autoUpdate()
````
You dont like the amount of lines you need for that? No problem, this does 1-1 the same thing as above:
````lua
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()
````