Example - Controlling Redstone output with a slider #25

Merged
toastonrye merged 7 commits from master into master 2022-08-09 09:10:08 +08:00
Showing only changes of commit c775958254 - Show all commits

View File

@@ -6,3 +6,44 @@ end
-- toastonrye's example: Redstone Analog Output
local basalt = require(filePath:gsub(".lua", "")) -- here you can change the variablename in any variablename you want default: basalt
local w, h = term.getSize()
local main = basalt.createFrame()
:show()
:setBackground(colours.blue)
local sub = main:addFrame()
:setPosition(2,2)
:setSize(w-2,h-2)
:setBackground(colours.lightBlue)
local rFrame = sub:addFrame("redstoneFrame")
:setPosition(1,1)
:setSize(25,5)
:setMoveable(true)
:setBackground(colours.red)
-- Redstone Analog Output
local redstoneAnalog = rFrame:addLabel()
:setPosition(18,3):setText("1")
redstone.setAnalogOutput("left", 1)
rFrame:addLabel()
:setText("Redstone Analog Output")
:setPosition(1,2)
rFrame:addSlider()
:setPosition(1,3)
:onChange(function(self)
redstoneAnalog:setText(self:getValue())
end)
:setMaxValue(15)
:setSize(15,1)
redstoneAnalog:onChange(function(self)
redstone.setAnalogOutput("left", tonumber(self:getValue()))
basalt.debug(self:getValue())
end)
basalt.autoUpdate()