Advertisement
Guest User

tst

a guest
May 1st, 2015
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. local arg = {...}
  2. dir = arg[1]
  3. file = arg[2]
  4. file = fs.open(dir .. "/" .. file, "r")
  5. local fileData = {}
  6. local line = file.readLine()
  7. x = 1
  8. repeat
  9. table.insert(fileData, line)
  10. line = file.readLine()
  11. x = x + 1
  12. until line == nil
  13. file.close()
  14. for i=1, x-1 do
  15.   op = tonumber(fileData[i])
  16.   if op == -1 then
  17.     turtle.back()
  18.   elseif op == 0 then
  19.     turtle.forward()
  20.   elseif op == 1 then
  21.     turtle.turnRight()
  22.   elseif op == 2 then
  23.     turtle.turnLeft()
  24.   else
  25.     print("unkown op: " .. op)
  26.   end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement