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

i don't know what i'm doing wrong.

Started by SlaaLogic, 15 February 2013 - 06:58 AM
SlaaLogic #1
Posted 15 February 2013 - 07:58 AM
i'm making an underground base and since i'fe done nothing with coding so far i wanted to make it with redpower2 and computercraft. but my coding is aparently not the best. no mather what i enter i get back the line: the pod is on its way down.
even when i am typing the n. what am i doing wrong?
code is below pls help me.


term.clear()
term.setCursorPos(1, 1)
local input
print("do you want to call the pod?")
print()
print("y/n")
print()
input = read()
-- answer to the question: do you want to call the pod
if input == "y" or "Y" then
  print("the pod is on it's way down")
elseif input == "n" or "N" then
  print("do you want to send the pod up?")
  print()
  print("y/n")
  print()
  input = read()
  if input == "y" or "Y" then
    print("the pod is on its way up")
  elseif input == "n"or"N" then
    print("okay the pod will stay where it is")
  else
    print("that is not a valid input, please try again") 
  end  
else
  print("that is not a valid input please try again")
end
Edited by
Lyqyd #2
Posted 15 February 2013 - 08:00 AM
Split into new topic.

You'll want to either use:

if input == "y" or input =="Y" then

or:

if string.lower(input) == "y" then

because what you have is like saying, "If the input is equal to "y", or if "Y" is not nil or false, then". "Y" is never nil or false (it's always "Y"), so it always takes that code path.
SlaaLogic #3
Posted 15 February 2013 - 08:25 AM
wooot soo hapy right now. you made my day!!!!!