Posted 10 June 2012 - 12:08 PM
Hello everyone
My Name is Ed and in my real job I do a lot of machine programming, process control and batching type systems. I haven't had any formal training in programming but have learned quite a lot on my own. I love Minecraft and computercraft is an excellent mod for other mods like redpower and powercraft etc. I am currently working on a program that will poll all the wires in a bundle and give its status. If someone would please look at what I've written and show me how to use maybe a table and loops to polish it up. Also maybe show me how to have it change sides or poll the sides to see which has a bundle then test it for status. It does work as is but I think someone with a little more knowledge than me could make it look better.
Please note I know I didn't add all the colors it would have been to long :(/>/>
function cls()
term.clear()
term.setCursorPos(1,1)
end
function startdisplay()
display = peripheral.wrap("top")
display.setTextScale(2)
display.clear()
display.setCursorPos(1,1)
end
function testbundleback()
cwhite = rs.testBundledInput("back", 1) – white true = on False = off
corange = rs.testBundledInput("back", 2) – orange
cmagenta = rs.testBundledInput("back", 4) – magenta
clightBlue = rs.testBundledInput("back", 8) – lightBlue
cyellow = rs.testBundledInput("back", 16) – yellow
clime = rs.testBundledInput("back", 32) – lime
cpink = rs.testBundledInput("back", 64) – pink
cgrey = rs.testBundledInput("back", 128) – grey
clightgrey = rs.testBundledInput("back", 256) – light-grey
ccyan = rs.testBundledInput("back", 512) – cyan
cpurple = rs.testBundledInput("back", 1024) – purple
cblue = rs.testBundledInput("back", 2048) – blue
cbrown = rs.testBundledInput("back", 4096) – brown
cgreen = rs.testBundledInput("back", 8192) – green
cred = rs.testBundledInput("back", 16384) – red
cblack = rs.testBundledInput("back", 32768) – black
end
for i=1,10 do
cls()
startdisplay()
testbundleback()
display.setCursorPos(1,1)
display.write("Test ")
display.write(i)
if cwhite == true then
[indent=1]display.setCursorPos(1,2)[/indent]
[indent=1]display.write("White is On")[/indent]
else
[indent=1]display.setCursorPos(1,2)[/indent]
[indent=1]display.write("White is Off")[/indent]
end
if corange == true then
[indent=1]display.setCursorPos(1,3)[/indent]
[indent=1]display.write("Orange is On")[/indent]
else
[indent=1]display.setCursorPos(1,3)[/indent]
[indent=1]display.write("Orange is Off")[/indent]
end
if cmagenta == true then
[left]display.setCursorPos(1,4)[/left]
[indent=1]display.write("Magenta is On")[/indent]
else
[indent=1]display.setCursorPos(1,4)[/indent]
[indent=1]display.write("Magenta is Off")[/indent]
end
sleep(2)
end
startdisplay()
display.write("Test Complete")
My Name is Ed and in my real job I do a lot of machine programming, process control and batching type systems. I haven't had any formal training in programming but have learned quite a lot on my own. I love Minecraft and computercraft is an excellent mod for other mods like redpower and powercraft etc. I am currently working on a program that will poll all the wires in a bundle and give its status. If someone would please look at what I've written and show me how to use maybe a table and loops to polish it up. Also maybe show me how to have it change sides or poll the sides to see which has a bundle then test it for status. It does work as is but I think someone with a little more knowledge than me could make it look better.
Please note I know I didn't add all the colors it would have been to long :(/>/>
function cls()
term.clear()
term.setCursorPos(1,1)
end
function startdisplay()
display = peripheral.wrap("top")
display.setTextScale(2)
display.clear()
display.setCursorPos(1,1)
end
function testbundleback()
cwhite = rs.testBundledInput("back", 1) – white true = on False = off
corange = rs.testBundledInput("back", 2) – orange
cmagenta = rs.testBundledInput("back", 4) – magenta
clightBlue = rs.testBundledInput("back", 8) – lightBlue
cyellow = rs.testBundledInput("back", 16) – yellow
clime = rs.testBundledInput("back", 32) – lime
cpink = rs.testBundledInput("back", 64) – pink
cgrey = rs.testBundledInput("back", 128) – grey
clightgrey = rs.testBundledInput("back", 256) – light-grey
ccyan = rs.testBundledInput("back", 512) – cyan
cpurple = rs.testBundledInput("back", 1024) – purple
cblue = rs.testBundledInput("back", 2048) – blue
cbrown = rs.testBundledInput("back", 4096) – brown
cgreen = rs.testBundledInput("back", 8192) – green
cred = rs.testBundledInput("back", 16384) – red
cblack = rs.testBundledInput("back", 32768) – black
end
for i=1,10 do
cls()
startdisplay()
testbundleback()
display.setCursorPos(1,1)
display.write("Test ")
display.write(i)
if cwhite == true then
[indent=1]display.setCursorPos(1,2)[/indent]
[indent=1]display.write("White is On")[/indent]
else
[indent=1]display.setCursorPos(1,2)[/indent]
[indent=1]display.write("White is Off")[/indent]
end
if corange == true then
[indent=1]display.setCursorPos(1,3)[/indent]
[indent=1]display.write("Orange is On")[/indent]
else
[indent=1]display.setCursorPos(1,3)[/indent]
[indent=1]display.write("Orange is Off")[/indent]
end
if cmagenta == true then
[left]display.setCursorPos(1,4)[/left]
[indent=1]display.write("Magenta is On")[/indent]
else
[indent=1]display.setCursorPos(1,4)[/indent]
[indent=1]display.write("Magenta is Off")[/indent]
end
sleep(2)
end
startdisplay()
display.write("Test Complete")