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

- 178

Started by milkywave1, 21 November 2012 - 11:33 PM
milkywave1 #1
Posted 22 November 2012 - 12:33 AM
I don't know why, but when I run my program, it just said '178' on the screen without performing the program. I've seen other error reports about this, but I still can't fix it. Here's the code:

rednet.open("right")
white = rs.testBundledInput("left", 1)
orange = rs.testBundledInput("left", 2)
magenta = rs.testBundledInput("left", 4)
lightBlue = rs.testBundledInput("left", 8)
yellow = rs.testBundledInput("left", 16)
while true do
if white == true then
rednet.send(5, "w")
else if orange == true then
rednet.send(5, "d")
else if magenta == true then
rednet.send(5, "s")
else if lightBlue == true then
rednet.send(5, "a")
else if yellow == true then
rednet.send(5, "r")
end
end
end
end
end
remiX #2
Posted 22 November 2012 - 01:30 AM
'elseif' is one word. You don't need an end for each elseif. You wil need to add a sleep(0) so it doesn't error and put the colours within the loop so it updates too.

rednet.open("right")

while true do
    white = rs.testBundledInput("left", 1)
    orange = rs.testBundledInput("left", 2)
    magenta = rs.testBundledInput("left", 4)
    lightBlue = rs.testBundledInput("left", 8)
    yellow = rs.testBundledInput("left", 16)
    if white then
        rednet.send(5, "w")
    elseif orange then
        rednet.send(5, "d")
    elseif magenta then
        rednet.send(5, "s")
    elseif lightBlue then
        rednet.send(5, "a")
    elseif yellow then
        rednet.send(5, "r")
    end
    sleep(0)
end
milkywave1 #3
Posted 25 November 2012 - 01:19 AM
'elseif' is one word. You don't need an end for each elseif. You wil need to add a sleep(0) so it doesn't error and put the colours within the loop so it updates too.
rednet.open("right") while true do white = rs.testBundledInput("left", 1) orange = rs.testBundledInput("left", 2) magenta = rs.testBundledInput("left", 4) lightBlue = rs.testBundledInput("left", 8) yellow = rs.testBundledInput("left", 16) if white then rednet.send(5, "w") elseif orange then rednet.send(5, "d") elseif magenta then rednet.send(5, "s") elseif lightBlue then rednet.send(5, "a") elseif yellow then rednet.send(5, "r") end sleep(0) end
Thanks! It works perfectly now ! :D/>/>