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

light system with ON/OFF function

Started by jay5476, 13 July 2012 - 05:55 AM
jay5476 #1
Posted 13 July 2012 - 07:55 AM
okay this is a cool program i use for my world(survival) and i find it very useful
for controling the light around my house the code is this


term.clear()
term.setCursorPos()
textutils.slowPrint("|—————————-|")
textutils.slowPrint("| Light System Pro V 2.4 |")
textutils.slowPrint("|—————————-|")
numb = math.random(1, 50)
numb2 = math.random(51, 99)
rest = math.random(1, 7)
lighton = "ON"
lightoff = "OFF"
out = "EXIT"
print("\nAcheiving Light Speed")
print("Progress "..numb.."%")
sleep(rest)
print("Progress "..numb2.."%")
sleep(rest)
textutils.slowPrint("100% Light Speed Acheived")
sleep(2)
term.clear()
term.setCursorPos(1,1)
while true do
print("|—————————-|")
print("| Light System Pro V 2.4 |")
print("|—————————-|")
print("\n Do You Want Lights ON or OFF or Type EXIT To Leave")
print("\nPlease Type How You See It Above")
input = read()
if input == lighton then
print("Lights On")
rs.setOutput("back",true)
sleep(2)
term.clear()
term.setCursorPos(1,1)
elseif input == lightoff then
print("Lights Off")
rs.setOutput("back",false)
sleep(2)
term.clear()
term.setCursorPos(1,1)
elseif input == out then
print("Bye")
sleep(1)
exit() – dont now how to get this to work? if i put break i get errors that continue forever please
– help
term.clear()
term.setCursorPos(1,1)
end
elseif
print("I Didn't Get You Try Again") then
sleep(1.5)
term.clear()
term.setCursorPos(1,1)
end
end

please help me fix this it works fine just doing ON?OFF commands
Bansheebandit #2
Posted 24 October 2012 - 01:29 AM
For a simple lighting system, this seems rather extreme…
stilldabomb #3
Posted 24 October 2012 - 01:39 AM
For your exit, try "return"
PixelToast #4
Posted 24 October 2012 - 01:57 AM
 tags plz ^_^/>/>
[size=1]not that anyone needs it anyway....[/size]
mattinator123 #5
Posted 24 October 2012 - 06:22 AM
or you could use a lever…

but nice attempt
robhol #6
Posted 24 October 2012 - 06:29 AM
Read up on the KISS principle, this program should be something like 4 lines.