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

(HELP!) With coding!

Started by con2000, 31 March 2012 - 11:02 PM
con2000 #1
Posted 01 April 2012 - 01:02 AM
y = "y"

im new to Computercraft and i'm testing something with Bundled Cables, and it says line 13 then expected


n = "n"

c = rs.setBundledOutput ( "back" )

if c == colors.lime false then print ("lights off")
write ("turn lights on?")
input == read()
if input == y then
rs.setBundledOutput ( "back", colors.lime )
elseif input == n then
os.shutdown()
elseif c == colors.lime true then
print ("lights on")
write ("trun them off")
input == read()
if input == y then
rs.setBundledOutput ( "back", colors.lime )
elseif input == n then
os.shutdown()
end
Advert #2
Posted 01 April 2012 - 01:07 AM
Please read the guidelines, and the stickies in this forum. By following them, you help us help you.
con2000 #3
Posted 01 April 2012 - 01:21 AM
OK! :o/>/>
Luanub #4
Posted 01 April 2012 - 01:28 AM
Your if syntax is wrong. You go from if to if with no end. Proper syntax is..


if
code
end

if
code
elseif
code
end

if
code
elseif
code
else
code
end

You can only have one if, one else, must have 1 end at the end of the if statement of coarse, and can use elseif as many times as you want.
con2000 #5
Posted 01 April 2012 - 01:31 AM
Thanks that helped so much :o/>/>
Advert #6
Posted 01 April 2012 - 01:32 AM
Your if syntax is wrong. You go from if to if with no end. Proper syntax is..


if
code
end

if
code
elseif
code
end

if
code
elseif
code
else
code
end

You can only have one if, one else, must have 1 end at the end of the if statement of coarse, and can use elseif as many times as you want.


Another thing worth noting is that elseif and else if are two different things entirely.