SHOW:
|
|
- or go back to the newest paste.
| 1 | --Basalt configurated installer | |
| 2 | local filePath = "basalt.lua" --here you can change the file path default: basalt | |
| 3 | if not(fs.exists(filePath))then | |
| 4 | shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
| |
| 5 | end | |
| 6 | ||
| 7 | -- toastonrye's example: Redstone Analog Output | |
| 8 | local basalt = require(filePath:gsub(".lua", "")) -- here you can change the variablename in any variablename you want default: basalt
| |
| 9 | - | local w, h = term.getSize() |
| 9 | + | local w, h = term.getSize() -- dimensions to use when drawing the sub frame |
| 10 | ||
| 11 | local main = basalt.createFrame() | |
| 12 | :show() | |
| 13 | - | :setBackground(colours.blue) |
| 13 | + | :setBackground(colours.blue) -- using colours to easily determine what frame I'm in |
| 14 | ||
| 15 | local sub = main:addFrame() | |
| 16 | :setPosition(2,2) | |
| 17 | :setSize(w-2,h-2) | |
| 18 | :setBackground(colours.lightBlue) | |
| 19 | ||
| 20 | local rFrame = sub:addFrame("redstoneFrame")
| |
| 21 | :setPosition(1,1) | |
| 22 | :setSize(25,5) | |
| 23 | - | :setMoveable(true) |
| 23 | + | :setMoveable(true) -- the next release of Basalt will fix spelling to :setMovable |
| 24 | :setBackground(colours.red) | |
| 25 | ||
| 26 | -- Redstone Analog Output | |
| 27 | - | local redstoneAnalog = rFrame:addLabel() |
| 27 | + | local redstoneAnalog = rFrame:addLabel() -- label that displays the value of the slider & Redstone output |
| 28 | :setPosition(18,3):setText("1")
| |
| 29 | ||
| 30 | - | redstone.setAnalogOutput("left", 1)
|
| 30 | + | redstone.setAnalogOutput("left", 1) -- initialize the redstone output to 1, to match the above label
|
| 31 | ||
| 32 | - | rFrame:addLabel() |
| 32 | + | rFrame:addLabel() -- draw a label on the frame |
| 33 | :setText("Redstone Analog Output")
| |
| 34 | :setPosition(1,2) | |
| 35 | ||
| 36 | rFrame:addSlider() | |
| 37 | :setPosition(1,3) | |
| 38 | - | :onChange(function(self) |
| 38 | + | :onChange(function(self) -- when a player interacts with the slider, update the variable redstoneAnalog |
| 39 | redstoneAnalog:setText(self:getValue()) | |
| 40 | end) | |
| 41 | - | :setMaxValue(15) |
| 41 | + | :setMaxValue(15) -- max value of the slider, default 8. Redstone has 15 levels (16 including 0) |
| 42 | - | :setSize(15,1) |
| 42 | + | :setSize(15,1) -- draw the slider to this size, without this redstoneAnalog value can have decimals |
| 43 | ||
| 44 | - | redstoneAnalog:onChange(function(self) |
| 44 | + | redstoneAnalog:onChange(function(self) -- when the slider value changes, change the Redstone output to match |
| 45 | redstone.setAnalogOutput("left", tonumber(self:getValue()))
| |
| 46 | basalt.debug(self:getValue()) | |
| 47 | end) | |
| 48 | ||
| 49 | basalt.autoUpdate() |