Updated How To (markdown)
35
How-To.md
35
How-To.md
@@ -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()
|
||||
````
|
||||
Reference in New Issue
Block a user