From 6ae0242b003332850a82a491278ea18713227d6e Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 16:45:39 -0500 Subject: [PATCH 1/7] Create redstoneAnalogOutput.lua --- redstoneAnalogOutput.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 redstoneAnalogOutput.lua diff --git a/redstoneAnalogOutput.lua b/redstoneAnalogOutput.lua new file mode 100644 index 0000000..4a43f5d --- /dev/null +++ b/redstoneAnalogOutput.lua @@ -0,0 +1,10 @@ +-- Basalt configurated installer +local filePath = "basalt.lua" -- here you can change the file path default: basalt.lua +if not(fs.exists(filePath))then + shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command +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 main = basalt.createFrame() -- 2.49.1 From 0cbded634af978fd80276dafe14e0aa7f21df6c5 Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 16:46:57 -0500 Subject: [PATCH 2/7] Delete redstoneAnalogOutput.lua --- redstoneAnalogOutput.lua | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 redstoneAnalogOutput.lua diff --git a/redstoneAnalogOutput.lua b/redstoneAnalogOutput.lua deleted file mode 100644 index 4a43f5d..0000000 --- a/redstoneAnalogOutput.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Basalt configurated installer -local filePath = "basalt.lua" -- here you can change the file path default: basalt.lua -if not(fs.exists(filePath))then - shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command -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 main = basalt.createFrame() -- 2.49.1 From 74071cb4bdc8667b49ced4159096ed78848e1feb Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 16:47:24 -0500 Subject: [PATCH 3/7] Create redstoneAnalogOutput.lua --- examples/redstoneAnalogOutput.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 examples/redstoneAnalogOutput.lua diff --git a/examples/redstoneAnalogOutput.lua b/examples/redstoneAnalogOutput.lua new file mode 100644 index 0000000..4a43f5d --- /dev/null +++ b/examples/redstoneAnalogOutput.lua @@ -0,0 +1,10 @@ +-- Basalt configurated installer +local filePath = "basalt.lua" -- here you can change the file path default: basalt.lua +if not(fs.exists(filePath))then + shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command +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 main = basalt.createFrame() -- 2.49.1 From 57b303f5389b590f317838724baf3b2f70bc1e09 Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 16:58:28 -0500 Subject: [PATCH 4/7] Update redstoneAnalogOutput.lua --- examples/redstoneAnalogOutput.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/redstoneAnalogOutput.lua b/examples/redstoneAnalogOutput.lua index 4a43f5d..ef4d287 100644 --- a/examples/redstoneAnalogOutput.lua +++ b/examples/redstoneAnalogOutput.lua @@ -1,10 +1,7 @@ --- Basalt configurated installer -local filePath = "basalt.lua" -- here you can change the file path default: basalt.lua +local filePath = "basalt.lua" --here you can change the file path default: basalt.lua if not(fs.exists(filePath))then - shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command + shell.run("pastebin run ESs1mg7P packed true "..filePath) -- this is an alternative to the wget command 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 main = basalt.createFrame() -- 2.49.1 From 1c76130086a1a4fd83903e1cf273911da03ff66e Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 17:09:35 -0500 Subject: [PATCH 5/7] Update redstoneAnalogOutput.lua --- examples/redstoneAnalogOutput.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/redstoneAnalogOutput.lua b/examples/redstoneAnalogOutput.lua index ef4d287..d69e0c0 100644 --- a/examples/redstoneAnalogOutput.lua +++ b/examples/redstoneAnalogOutput.lua @@ -1,6 +1,7 @@ -local filePath = "basalt.lua" --here you can change the file path default: basalt.lua +--Basalt configurated installer +local filePath = "basalt.lua" --here you can change the file path default: basalt if not(fs.exists(filePath))then - shell.run("pastebin run ESs1mg7P packed true "..filePath) -- this is an alternative to the wget command + shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command end -- toastonrye's example: Redstone Analog Output -- 2.49.1 From c775958254b94fadfcb8c5ded425922735eae4a5 Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 19:33:51 -0500 Subject: [PATCH 6/7] Update redstoneAnalogOutput.lua Uploaded from pastebin --- examples/redstoneAnalogOutput.lua | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/examples/redstoneAnalogOutput.lua b/examples/redstoneAnalogOutput.lua index d69e0c0..da1b262 100644 --- a/examples/redstoneAnalogOutput.lua +++ b/examples/redstoneAnalogOutput.lua @@ -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() -- 2.49.1 From fac7e221b3a6410e148da579aae94bb6ef4d4f01 Mon Sep 17 00:00:00 2001 From: toastonrye Date: Mon, 8 Aug 2022 19:44:24 -0500 Subject: [PATCH 7/7] Update redstoneAnalogOutput.lua Add comments --- examples/redstoneAnalogOutput.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/redstoneAnalogOutput.lua b/examples/redstoneAnalogOutput.lua index da1b262..41ddc99 100644 --- a/examples/redstoneAnalogOutput.lua +++ b/examples/redstoneAnalogOutput.lua @@ -6,11 +6,11 @@ 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 w, h = term.getSize() -- dimensions to use when drawing the sub frame local main = basalt.createFrame() :show() - :setBackground(colours.blue) + :setBackground(colours.blue) -- using colours to easily determine what frame I'm in local sub = main:addFrame() :setPosition(2,2) @@ -20,28 +20,28 @@ local sub = main:addFrame() local rFrame = sub:addFrame("redstoneFrame") :setPosition(1,1) :setSize(25,5) - :setMoveable(true) + :setMoveable(true) -- the next release of Basalt will fix spelling to :setMovable :setBackground(colours.red) -- Redstone Analog Output -local redstoneAnalog = rFrame:addLabel() +local redstoneAnalog = rFrame:addLabel() -- label that displays the value of the slider & Redstone output :setPosition(18,3):setText("1") -redstone.setAnalogOutput("left", 1) +redstone.setAnalogOutput("left", 1) -- initialize the redstone output to 1, to match the above label -rFrame:addLabel() +rFrame:addLabel() -- draw a label on the frame :setText("Redstone Analog Output") :setPosition(1,2) rFrame:addSlider() :setPosition(1,3) - :onChange(function(self) + :onChange(function(self) -- when a player interacts with the slider, update the variable redstoneAnalog redstoneAnalog:setText(self:getValue()) end) - :setMaxValue(15) - :setSize(15,1) + :setMaxValue(15) -- max value of the slider, default 8. Redstone has 15 levels (16 including 0) + :setSize(15,1) -- draw the slider to this size, without this redstoneAnalog value can have decimals -redstoneAnalog:onChange(function(self) +redstoneAnalog:onChange(function(self) -- when the slider value changes, change the Redstone output to match redstone.setAnalogOutput("left", tonumber(self:getValue())) basalt.debug(self:getValue()) end) -- 2.49.1