Mr_Rockers

Untitled

Nov 16th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. howFarDist = 0
  2.  
  3. function howFarFunc()
  4. howFarDist = read()
  5.  
  6. if tonumber(howFarDist) ~= nil then
  7.     howFarDist = tonumber(howFarDist)
  8. else
  9.     textutils.slowPrint("Please enter a numeric value")
  10.     sleep(1)
  11.     term.clear()
  12.     textutils.slowPrint("How far would you like to go?")
  13.     howFarFunc()
  14. end
  15.  
  16.     if howFarDist <= 0 then
  17.         textutils.slowPrint("You cannot move the turtle")
  18.         textutils.slowPrint("0 or less blocks, stupid.")
  19.         sleep(1)
  20.         term.clear()
  21.         textutils.slowPrint("How far would you like to go?")
  22.         howFarFunc()
  23.     end
  24. end
  25.  
  26. function confirm(direction)
  27. term.clear()
  28. textutils.slowPrint("So...")
  29. sleep(2)
  30. textutils.slowPrint("You would like the turtle to:")
  31. sleep(1)
  32. textutils.slowPrint("Travel "..howFarDist.." blocks.")
  33. textutils.slowPrint("(Facing "..direction..".)")
  34. sleep(1)
  35. textutils.slowPrint("Is this correct?")
  36. textutils.slowPrint("(Type Y for yes or anything else for no.)")
  37. YorNinput = read()
  38.  
  39. if YorNinput == "Y" then
  40.     term.clear()
  41.     textutils.slowPrint("Starting...")
  42.    
  43.     if direction == "left" then
  44.         turtle.turnLeft()
  45.     elseif direction == "right" then
  46.         turtle.turnRight()
  47.     elseif direction == "back" then
  48.         turtle.turnLeft()
  49.         turtle.turnLeft()
  50.     end
  51.  
  52.     sleep(1)
  53. else
  54.     term.clear()
  55.     textutils.slowPrint("Okay then... Restarting program.")
  56.     sleep(1)
  57.     term.clear()
  58.     Main()
  59. end
  60.  
  61. end
  62.  
  63. local howFar = "How far would you like to go "
  64.  
  65.  
  66. function Start()
  67. term.clear()
  68. Main()
  69. end
  70.  
  71. function Main()
  72. textutils.slowPrint("Hello user!")
  73. sleep(1)
  74. textutils.slowPrint("What direction do you want me")
  75. textutils.slowPrint("to go in?")
  76. local dirinput = read()
  77.  
  78. if dirinput == "left" then
  79. textutils.slowPrint(howFar.."left?")
  80. howFarFunc()
  81. confirm("left")
  82.  
  83. elseif dirinput == "right" then
  84. textutils.slowPrint(howFar.."right?")
  85. howFarFunc()
  86. confirm("right")
  87.  
  88. elseif dirinput == "forward" then
  89. textutils.slowPrint(howFar.."forward?")
  90. howFarFunc()
  91. confirm("forward")
  92.  
  93. elseif dirinput == "back" then
  94. textutils.slowPrint(howFar.."back?")
  95. howFarFunc()
  96. confirm("back")
  97.  
  98. else
  99. textutils.slowPrint("Please input either:")
  100. textutils.slowPrint("\"forward\"")
  101. sleep(1)
  102. textutils.slowPrint("\"back\"")
  103. sleep(1)
  104. textutils.slowPrint("\"left\"")
  105. sleep(1)
  106. textutils.slowPrint("or")
  107. sleep(1)
  108. textutils.slowPrint("\"right\"")
  109. sleep(2)
  110. textutils.slowPrint("Restarting program...")
  111. sleep(2)
  112. term.clear()
  113. Main()
  114. end
  115. end
  116.  
  117. Start()
Advertisement
Add Comment
Please, Sign In to add comment