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

Does This Script Have Any Bugs?

Started by Nikolai, 30 November 2012 - 06:25 AM
Nikolai #1
Posted 30 November 2012 - 07:25 AM
Can someone adapt this code to work with ribbon cable?




os.pullEvent = os.pullEventRaw
print 'Reactor Tempature Monitoring System'
while true do
blackin = rs.testBundledInput("back", colors.black)
redin = rs.testBundledInput("back", colors.black)
yellowin = rs.testBundledInput("back", colors.yellow)
bluein = rs.testBundledInput("back", colors.blue)
if blackin = true then
rs.setBundledOutput("back", colors.brown)
print 'Reactor Is Off'
if redin = true then
rs.setBundledOutput("back", colors.orange)
print 'Reactor Tempature At 3000'
if yellowin = true then
rs.setBundledInput("back", colors.green)
print 'Reactor Tempature At 5000"
if bluein = true then
rs.setOutput("left", true)
print 'Reactor Tempature Critical!'
if blackin == false then
rs.setBundledOutput("brown", 0)
if redin == false then
rs.setBundledOutput("orange", 0)
if yellowin == false then
rs.setBundledOutput("green", 0)
if bluein == false then
rs.setBundledOutput("purple", 0)
end
sleep(.1)
end
theeboris #2
Posted 30 November 2012 - 08:29 AM
You can test it. I don't think sleep(.1) works.
Nikolai #3
Posted 30 November 2012 - 08:33 AM
You can test it. I don't think sleep(.1) works.
You can test it. I don't think sleep(.1) works.

My concern is that I used setBundle, I wanted this script to work with ribbons not redstone bundles.
Sammich Lord #4
Posted 30 November 2012 - 08:34 AM
You should test your code then if you get any errors come post a topic in this section for help.
Lyqyd #5
Posted 30 November 2012 - 08:52 AM
Your code would be easier to deal with if you did this sort of thing instead:


if rs.testBundledInput("back", colors.black) then
  --code if black is high
else
  code if black is low
end

Use one of these for each color. Note that there is one end to close the if, and it goes after the else block.

I'm not going to point out the various other syntax errors, as that is what a lua interpreter is for.

Bundled cable is the only thing that the bundled input/output functions are for. ComputerCraft doesn't have any facility to interact with ribbon cable, so you'll have to use bundled cable instead.
remiX #6
Posted 30 November 2012 - 09:43 AM
I might be wrong but this could give a possible error:
print 'Reactor Tempature At 5000"
you should use the same " " or ' ' for print/write. So change it to
print 'Reactor Tempature At 5000'