Jump to content




'else' Function help


  • You cannot reply to this topic
2 replies to this topic

#1 Kadecamz

  • New Members
  • 113 posts

Posted 29 July 2012 - 03: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()
    


#2 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 29 July 2012 - 04: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.

#3 Kadecamz

  • New Members
  • 113 posts

Posted 29 July 2012 - 04:14 AM

My way of learning lua: Asking why my attempts don't work on the help forum. :ph34r:/>

Thank you





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users