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

lights

Started by Saxguy99, 02 April 2013 - 08:28 AM
Saxguy99 #1
Posted 02 April 2013 - 10:28 AM
make sure the redstone is behind your computer


print ("lights on or off")

input = read()

if input ==  "on" then
redstone.setOutput("back", true)
term.clear()
term.setCursorPos(1,1)

elseif input == "off" then
redstone.setOutput("back", false)
term.clear()
term.setCursorPos(1,1)

else

print ("Not a Valid Answer.")
sleep(3)
term.clear()
term.setCursorPos(1,1)

end
oeed #2
Posted 02 April 2013 - 01:38 PM
May I suggest you tell us what this does with out us having to read you code.

Also, remove the 'sleep(3)'. If you want to have a sleep in there, 1 second is the most you want.

I recommend putting a while loop around the entire thing so it will repeat it self, otherwise maybe add shell arguments.
Kingdaro #3
Posted 02 April 2013 - 01:44 PM
A nice little tip to prevent repetition, you seem to have "term.clear() term.setCursorPos(1,1)" listed under all of the conditions. Why not just throw it after the if?


print ("lights on or off")

input = read()

if input ==  "on" then
redstone.setOutput("back", true)

elseif input == "off" then
redstone.setOutput("back", false)

else
print ("Not a Valid Answer.")
sleep(3)

end

term.clear()
term.setCursorPos(1,1)

Otherwise it's a nice, solid program for a beginner.