Advertisement
Guest User

dirInterpreter

a guest
Feb 27th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. print("Which file would you like to load?")
  2. print("Tip: Include .lua")
  3. fileName = io.read()
  4.  
  5. file = fs.open(fileName , "r")
  6. directionList = {}
  7. count = 1
  8. for line in file.readLine do    
  9.         directionList[count] = line
  10.         count = count + 1  
  11. end
  12. file.close()
  13.  
  14. for i=1,#directionList do
  15.     local dir = directionList[i]  
  16.         dir = string.lower(dir)
  17.      if dir == "up" then
  18.         turtle.digUp()
  19.         turtle.up()
  20.      elseif dir == "down" then
  21.         turtle.digDown()
  22.         turtle.down()
  23.      elseif dir == "forward" then
  24.         turtle.dig()
  25.         turtle.forward()
  26.      elseif dir == "back" then
  27.         turtle.back()
  28.     elseif dir == "right" then
  29.         turtle.turnRight()
  30.     elseif dir == "left" then
  31.         turtle.turnLeft()
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement