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

having problems whit a consol based manu

Started by Anora, 04 February 2013 - 04:45 AM
Anora #1
Posted 04 February 2013 - 05:45 AM
I cant seam ti get this to work right.I have tried different things even the recommended method witch I'm using right now,


if input == "help" or "Help" then
   print("Available commands are:")
   print("left   Moves the unit 16 blocks to the left")
   print("right   Moves the unit 16 blocks to the right")
   print("fward   Moves the unit 16 blocks fward")
   print("revers   Moves the unit 16 blocks in revers")
   print("up   Moves the unit up in the amount you indicate")
   print("dig   Dose exactly what it said Dig's")
   local input = read()
elseif input == "left" or "Left" then
   Move_Left()

elseif input == "right" or "Right" then
   Move_Right()

elseif input == "up" or "Up" then
   Move_Up()

elsif input == "revers" or "Revers" then
   Move_Revers()

elseif input == "fward" or "Fward"then
   Move_Fward()

elseif input == "dig" or "Dig" then
   Dig()
end

this is not the entire app, this is whats not working right, dose not mater whit I write it pulse up the help right away and if I write something else it just quits in staid of doing what it should
king77 #2
Posted 04 February 2013 - 05:49 AM
You have to write
elseif input == "left" or input == "Left" then

Not
elseif input == "left" or "Left" then
Senmori #3
Posted 04 February 2013 - 05:50 AM

elsif input == "revers" or "Revers" then
   Move_Revers()

should be:


elseif input == "revers" or "Revers" then
	Move_Revers()

That's assuming, of course, you've defined all functions.
Kingdaro #4
Posted 04 February 2013 - 05:56 AM
No, that works you just wrote the code wrong

elsif input == "revers" or "Revers" then
   Move_Revers()

should be:


elseif input == "revers" or "Revers" then
    Move_Revers()

That's assuming, of course, you've defined all functions.

In this case, that's wrong. What king77 said is what OP wants to do, but you could also just do this:

elseif input:lower() == "up" then
   Move_Up()

So that the input is automatically lowercase. While fixing that "elsif" error in there as well.
Anora #5
Posted 04 February 2013 - 06:02 AM
yea my functions are all defined

thanks Kingdaro, seams your solutions was best and the helps I look at never said anything about adding input after or, shame on them
well least its working as intended now, now I just need to write a dinging routine using GPS