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

Bundled Cables And Digital Numbers Help

Started by Bladedemon70, 28 February 2012 - 01:00 AM
Bladedemon70 #1
Posted 28 February 2012 - 02:00 AM
Ok after my run in to seeing clock made with wireless redstone and computercraft I am on the pursuit of making and coding my own clock… and yes i am quite aware of the clock program in the program section but I could get it to work and so on but It ended up making me want to make my own…

Now i wanted to start small and decide to make a program that takes a single digit panel of redpower lamps and the program running through 1-9 and 0 but didnt go as planned…

Heres the code it is so messy to be honest and probably can be condensed majorly

Code:
Spoiler

-- Digital number wireless test
--Clear all function
function clearall()
term.clear()
term.setCursorPos(1,1)
end
--number functions
--number 1
function numberone()
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.yellow)
end
--number 2
function numbertwo()
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.magenta)
redstone.setBundledOutput("back", colors.red)
end
--number 3
function numberthree()
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.yellow)
end
--number 4
function numberfour()
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.yellow)
redstone.setBundledOutput("back", colors.magenta)
end
--number 5
function numberfive()
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.blue)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.yellow)
end
--number 6
function numbersix()
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.blue)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.magenta)
end
--number 7
function numberseven()
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.yellow)
redstone.setBundledOutput("back", colors.red)
end
--number 8
function numbereight()
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.blue)
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.yellow)
redstone.setBundledOutput("back", colors.magenta)
end
--number 9
function numbernine()
redstone.setBundledOutput("back", colors.black)
redstone.setBundledOutput("back", colors.yellow)
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.magneta)
end
--number 0
function numberzero()
redstone.setBundledOutput("back", colors.red)
redstone.setBundledOutput("back", colors.green)
redstone.setBundledOutput("back", colors.blue)
redstone.setBundledOutput("back", colors.cyan)
redstone.setBundledOutput("back", colors.yellow)
redstone.setBundledOutput("back", colors.magenta)
end
--main program
print ("This program will now start the test.")
sleep(1)
print ("Count down to start...")
sleep(1)
print ("5")
sleep(1)
print ("4")
sleep (1)
print ("3")
sleep (1)
print ("2")
sleep (1)
print ("1")
sleep (1)
print ("Starting Procedure...")
sleep(.5)
numberone()
print ("1")
sleep(2)
numbertwo()
print ("2")
sleep(2)
numberthree()
print ("3")
sleep(2)
numberfour()
print ("4")
sleep(2)
numberfive()
print ("5")
sleep(2)
numbersix()
print ("6")
sleep(2)
numberseven()
print ("7")
sleep(2)
numbereight()
print ("8")
sleep(2)
numbernine()
print ("9")
sleep(2)
numberzero()
print ("0")
sleep(2)
print ("Done running test.")
sleep(1)
print ("Goodbye")
sleep(1)
clearall()
os.reboot()

Edit:

This might help… screenshot of what i have set up
SpoilerImage1 [back view reciever to wire to lamp setup]
Spoiler

Image 2: [front view with the computer to bundled cable to wire to transmitter setup]
Spoiler
Casper7526 #2
Posted 28 February 2012 - 02:13 AM
Just to help you shorten things if you did wanna do this sorta route.
number = {}
number[1] = colors.red + colors.yellow
number[2] = colors.red + colors.magenta + colors.green + colors.black + colors.cyan
ect ect

for x = 1, 2 do
rs.setBundledOutput("back", number[x])
sleep(2)
end
Bladedemon70 #3
Posted 28 February 2012 - 02:30 AM
ok ill post what i get from your post and see if i did it right but to clarify things for my nooby brain:

1) the number ={} this i just list all the numbers as variables and set them equal to the color values of the wires to make them light up in the shape of the number

2) the second thing is a loop function???? that set the outputs but using the number varibles i assume

^^^
things in parenthesis all assumptions… like i said i have a nooby brain at least with coding
Casper7526 #4
Posted 28 February 2012 - 02:39 AM
number = {} – tells our program that "number" is now a blank table
number[1] = colors.red + colors.yellow – places those colors into number[1] which is the 1st slot of the number table
number[2] = colors.red + colors.magenta + colors.green + colors.black + colors.cyan
ect ect

for x = 1, 2 do — x starts at 1 and will increase by 1 until it reaches 2 (in this version it would just go 1 then 2) for x = 0,9 do (that would do 0,1,2,3,4,5,6,7,8,9)
rs.setBundledOutput("back", number[x]) – sets the output to number[x] where x represents which loop we are in (1 then 2 then 3 etc etc)
sleep(2)
end
Bladedemon70 #5
Posted 28 February 2012 - 02:52 AM
ok thanks for the great help and even better explaination ill get on it condensing this monster