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

Help with my simple program!

Started by Coocoo99947, 02 July 2016 - 04:47 PM
Coocoo99947 #1
Posted 02 July 2016 - 06:47 PM
I am playing on Tekkit Main (A Technic Platform modpack) and I am trying to make a program that will keep travelling upwards until the player types "Stop".

This is my code:

print("Please type Stop when you wish to stop:")
Stop = read()
repeat
turtle.up()
until Stop == "Stop"
end

Is anyone able to help me with this?

Greatly Appreciated
-Coocoo99947
eniallator #2
Posted 02 July 2016 - 11:20 PM
this should work:

local function goUp()
  while true do turtle.up() end
end

local function getInput()
  local userInput
  repeat
    userInput = read()
  until userInput == "Stop" -- #or you can have "until userInput:lower() == 'stop'" which would be easier for the user
end

parallel.waitForAny(goUp,getInput)
Edited on 02 July 2016 - 09:20 PM