Advertisement
Guest User

GPSa0.84

a guest
Oct 20th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. if posx == nil then posx = 1 end
  2. if posy == nil then posy = 0 end
  3.  
  4. if fieldx == nil then fieldx = 9 end
  5. if fieldy == nil then fieldy = 9 end
  6.  
  7. if wait == nil then wait = 540 end
  8. if waitafter == nil then waitafter = true
  9.  
  10. function mine()
  11.     print("doing stuff here")
  12. end
  13.  
  14. function move(dx, dy)
  15.     moveDirX(posx, dx)
  16.     moveDirY(posy, dy)
  17. end
  18.  
  19. function moveDirX(ax, dx)
  20.     delta = ax-dx
  21.     if delta < 0 then step(delta, 0)
  22.     elseif delta > 0 then step(delta, 0)
  23.     else print("Nothing to do in X-Direction")
  24. end
  25.  
  26. function moveDirY(ay, dy)
  27.     delta = ay-dy
  28.     if delta < 0 then step(delta, 1)
  29.     elseif delta > 0 then step(delta, 1)
  30.     else print("Nothing to do in Y-Direction")
  31. end
  32.  
  33. function betrag(zahl1)
  34.     if zahl1 < 0 then return zahl1 * -1
  35.     else return zahl1
  36.     end
  37. end
  38.  
  39. function step(count, axis)
  40.     if axis == 0 then
  41.         for i=1, betrag(count) do
  42.             if count > 0 then
  43.                 moveRight()
  44.                 return true
  45.             elseif count < 0 then
  46.                 moveLeft()
  47.                 return true
  48.             end
  49.         end
  50.     elseif axis == 1 then
  51.         for i=1, betrag(count) do
  52.             if count > 0 then
  53.                 moveForward()
  54.                 return true
  55.             elseif count < 0 then
  56.                 moveBack()
  57.                 return true
  58.             end
  59.         end
  60.     end
  61.    
  62. end
  63.  
  64. function moveRight()
  65.     print("Moving to the right. New coordinates should be: "..posx+1.." / "..posy)
  66. end
  67.  
  68. function moveLeft()
  69.     print("Moving to the right. New coordinates should be: "..posx-1.." / "..posy)
  70. end
  71.  
  72. function moveForward()
  73.     print("Moving to the right. New coordinates should be: "..posx.." / "..posy+1)
  74. end
  75.  
  76. function moveBack()
  77.     print("Moving to the right. New coordinates should be: "..posx.." / "..posy-1)
  78. end
  79.  
  80.  
  81.  
  82.  
  83. if not waitafter then sleep(wait)
  84.  
  85. --.....
  86. move(1,1)
  87.  
  88. if waitafter then sleep(wait)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement