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

'else' Function help

Started by Kadecamz, 29 July 2012 - 02:55 AM
Kadecamz #1
Posted 29 July 2012 - 04:55 AM
Why doesn't the else command work?
I'm getting trouble at line 14.
  • 
    
    conventinal = ("1337")
    
    heavy = ("2448")
    
    textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
    input = read()
    
    if  input == conventinal then
    rs.setOutput ("left", true)
    
    elseif input == heavy then
    rs.setOutput ("right", true)
    
    if input == else then 
    textutils.slowPrint("CODE INVALID!!! SHUTTING DOWN")
    os.shutdown
    
    end
    
    sleep(1)
    textutils.slowWrite ("Missiles are FIRING! Look in the sky!!!!")
    sleep(2) 
    textutils.slowWrite ("Action Completed")
    sleep(3)
    os.shutdown()
    
Tiin57 #2
Posted 29 July 2012 - 05:12 AM

conventinal = "1337"
heavy = "2448"
textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
input = read()
if  input == conventinal then
rs.setOutput ("left", true)
elseif input == heavy then
rs.setOutput ("right", true)
else --You don't need to put if input == else, just else will work. That's where your error was.
textutils.slowPrint("CODE INVALID!!! SHUTTING DOWN")
os.shutdown() --You forgot () at the end there.
end
sleep(1)
textutils.slowWrite ("Missiles are FIRING! Look in the sky!!!!")
sleep(2)
textutils.slowWrite ("Action Completed")
sleep(3)
os.shutdown()
Hope that fixes it.
Kadecamz #3
Posted 29 July 2012 - 05:14 AM
My way of learning lua: Asking why my attempts don't work on the help forum. :ph34r:/>/>

Thank you