Advertisement
Zonkotron

String handling in Computercraft test

Jan 26th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function mv(x)
  2. if x == nil then
  3. x = "f"
  4. end
  5. print("Zonk")
  6.  
  7. print(x)
  8.  
  9. s = string.lower(x)
  10. l = string.len(s) -- length of string
  11.  
  12. print(s)
  13. print(l)
  14. print("Zonk")
  15.  
  16. for i=1,l,1 do
  17. e = string.sub(s,i,i)
  18. if e=="f" then
  19. turtle.forward()
  20. elseif e == "b" then
  21. turtle.back()
  22. elseif e == "d" then
  23. turtle.down()
  24. elseif e == "u" then
  25. turtle.up()
  26. elseif e == "r" then
  27. turtle.turnRight()
  28. elseif e == "l" then
  29. turtle.turnLeft()
  30. elseif e == "t" then
  31. turtle.turnRight()
  32. turtle.turnRight()
  33. else
  34. print ("Wrong Move *mv* input character")
  35. return(0)
  36.  
  37. end
  38. end
  39. end
  40.  
  41. mv("fffrffflbbuutffdd")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement