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

"then" expected

Started by Conrflakes, 06 January 2018 - 08:42 PM
Conrflakes #1
Posted 06 January 2018 - 09:42 PM
Try to do a Prgram for an Elevator

If I try to start it, I get following Error "then" expectet at line 14

I don't understand wherer the problem is


os.pullEvent("redstone")

while true do
    if rs.testBundledInput("left", colors.white)) then
	    if Etage == 1 then
		    rs.setBundledOutput("left", colors.lime)
		    sleep(1)
		    rs.setBundledOutput("left", colors.red)
	    else do
		    rs.setBundledOutput("left", colors.pink)
			    if colors.test(rs.setBundledInput("left"), colors.black) == true then
			    rs.setBundledOutput("left", colors.red)
			    end
		    end
	    end
    end
end
Bomb Bloke #2
Posted 06 January 2018 - 10:14 PM
Here:

if rs.testBundledInput("left", colors.white)) then

… you've got an additional closing bracket where a "then" would be more suitable.

Here:

else do

… you're opening two blocks. Just use "else".

Here:

if colors.test(rs.setBundledInput("left"), colors.black) == true then

… you're using "set" where you meant to use "get".
Conrflakes #3
Posted 06 January 2018 - 10:21 PM
Thanks, now it works