Advertisement
thewmatt

Pathfind

Oct 19th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. --precode
  2. shell.run("clear")
  3. print("V")
  4. A = .2 --the rate of the arrow
  5. Botx=1 -- coords of the arrow, or bot
  6. Boty=1
  7. char = "V" --the direction of the arrow
  8. --functions
  9. function place()
  10. scrap, scrap, bx, by = os.pullEvent("mouse_click")
  11. term.setCursorPos(bx,by)
  12. term.write("A")
  13. end
  14.  
  15. function DrawBot(bot)
  16. if bot ~= nil then
  17. char = bot
  18. bot = nil
  19. end
  20. term.clear()
  21. term.setCursorPos(bx,by)
  22. term.write("A")
  23. term.setCursorPos(Botx,Boty)
  24. term.write(char)
  25. end
  26. function Move()
  27. if Botx > bx then
  28. Botx = Botx-1
  29. char = "<"
  30. DrawBot()
  31. sleep(A)
  32. elseif Botx < bx then
  33. Botx = Botx+1
  34. char = ">"
  35. DrawBot()
  36. sleep(A)
  37. end
  38. if Boty > by then
  39. Boty = Boty-1
  40. char = "^"
  41. DrawBot()
  42. sleep(A)
  43. elseif Boty < by then
  44. Boty = Boty+1
  45. char = "v"
  46. DrawBot()
  47. sleep(A)
  48. end
  49. end
  50. function Manim()
  51. while Botx ~= bx or Boty ~= by do
  52. Move()
  53. end
  54. sleep(.5)
  55. term.clear()
  56. DrawBot("V")
  57. end
  58. --run code
  59. while true do
  60. place()
  61. Manim()
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement