This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Rug's profile picture

Dynamic Analog Output?

Started by Rug, 03 September 2014 - 10:14 AM
Rug #1
Posted 03 September 2014 - 12:14 PM
I am looking to create a staircase using Turtles/Computers and redstone. I would like to use about 15 turtles for 15 block spaces you can walk on: for rounding and because Analog Redstone Strength goes to 16.

http://imgur.com/a/UZ0sN (It wouldn't allow me to do a different way of embedding the photos, here is a link to an imgur album.

This image shows the wall that holds my barrels. I want to have the staircase (shown in white wool) to be built in front of the wall up to a limited height that is specified by the user. For example. if I ask the program to take me up 3 steps I'd expect the block placer to build in a scaling pattern that goes around 3 sides of a large cube. At the front would be the control interface and on the left right and back I have barrels with specific items.The items are not important, just the level the barrels sit at.

Since the staircase would have a set height depending on how far down it is in the row (0-16), i assume the turtles could all recognize the seperate strength value using rs.getAnalogInput from its backside. From there, im not sure how to translate the value of the RS signal into how many blocks I want it to place. I feel like with tonumber() or tostring() i should be able to recognize the value and convert it.

I had heard that certain blocks use the Analog input/output of redstone (0-16 Strength Value) so I tried to set the output of a computer using different things like

to declare a variable that uses read() to ask for a user to specify a number to be used as the rs.setAnalogOutput out the back of the machine then have the rs.setAnalog method already know where to output the signal but use a variable as it's output level so it can be declared on use instead of writing a seperate function or statement for every value.

The method is thrown because rs.setAnalogOutput asks for a ("string", number), I've been thinking of several work-arounds in case the command simply won't accept a dynamic variable for its strength. Including having a main touch screen with 1 - 16 in buttons then just tapping the button # you want. In this scenario, from my understanding, I'd need to tell the computer about how to act for each individual button.

Please let me know if this isn't clear enough, I can provide more pictures or context or whatever you need.

If you made it this far, thanks for reading and I hope you enjoy the rest of your day.
hilburn #2
Posted 03 September 2014 - 05:00 PM
there is absolutely nothing wrong with having something like:


local function buttonTouch(button_num)
   rs.setAnalogOutput("back",button_num)
end
Rug #3
Posted 03 September 2014 - 08:30 PM
First of all, thank you very much for your help!

If i were to implement it that way, where does button_num come from? Would I use a read()/tonumber() command to ask for the button number, or would I assign each button on screen a number as the paramater when I write the program?

Cheers!
hilburn #4
Posted 03 September 2014 - 10:04 PM
you could do either, but I definitely recommend the latter, a grid of buttons labelled 1-15 with a number (tbh you could even use the label of the button) associated with each that is passed to the on-click event
Rug #5
Posted 06 September 2014 - 04:00 AM
Thats true; Keep It Simple, Stupid. Thank you very much for your help, have a nice day!