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

Multiple Choices

Started by julllleee, 16 January 2013 - 02:38 AM
julllleee #1
Posted 16 January 2013 - 03:38 AM
Hi, Im trying to make a program that when i press 1 it should give a redstone signal, when i press 2 it should turn it off. I got a code but i can't get it to work.
print(" 1 = on, 2 = auto:")
while true do
term.setCursorPos(1,2)
term.clearLine()
if read() == "1" then
redstone signal here
print(" ON ")
sleep ( 1 )
return
end
elseif read() == "2" then
redstone signal off
print (" auto ")
sleep ( 1 )
return
end
end
print("Enter a number.")
sleep(2)
term.clearLine()
end
end


There might be some spelling errors in that one because if wrote it off the screen, im on a server so i can't copy. And where it says redstone signal on/off i got the real code but i just wrote that for you to understand it better.

The error i get when i try to run the code is 12: 'end' expected (to close 'while' at line 2)
I Have added end there but it don't work. Don't know if it matters but im playing on a 1.2.5 server with tekkit. So computercraft is version 1.3

Thanks :3
remiX #2
Posted 16 January 2013 - 03:52 AM
rs.setOutput("side", true) -- on
rs.setOutput("side", false) -- off 
theoriginalbit #3
Posted 16 January 2013 - 03:53 AM
Im on a server so i can't copy

If the http api is enabled type in "pastebin put <filename>"… to see if http api is enabled type "pastebin" if it shows usage its enabled, if it says no program, its disabled.

however the issue is here


end
elseif
no end is needed here

then you have 2 extra ends in there as well… i think, indenting sucks… confirmed, where you have double ends, remove one from each…
Edited on 16 January 2013 - 02:54 AM
julllleee #4
Posted 16 January 2013 - 04:00 AM
Im on a server so i can't copy

If the http api is enabled type in "pastebin put <filename>"… to see if http api is enabled type "pastebin" if it shows usage its enabled, if it says no program, its disabled.

however the issue is here


end
elseif
no end is needed here

then you have 2 extra ends in there as well… i think, indenting sucks… confirmed, where you have double ends, remove one from each…

aha, okay thanks now it work :)/>