Advertisement
Guest User

motion

a guest
May 22nd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. x,y,z,dir=0,0,0,0
  2. fuelSlot=1
  3. function refuel()
  4.   turtle.select(fuelSlot)
  5.   turtle.refuel(1)
  6. end
  7. function forward()
  8.   reussit=turtle.forward()
  9.   if not reussit then
  10.     if turtle.getFuelLevel()==0 then
  11.       refuel()
  12.     else
  13.       turtle.dig()
  14.     end
  15.     reussit=turtle.forward()
  16.   end
  17.   if reussit then
  18.     if dir==0 then
  19.       x=x+1
  20.     elseif dir==1 then
  21.       y=y+1
  22.     elseif dir==2 then
  23.       x=x-1
  24.     elseif dir==3 then
  25.       y=y-1
  26.     end
  27.   end
  28.   return reussit
  29. end
  30. function getPosition()
  31.   return x,y,z,dir
  32. end
  33. function getX()
  34.   return x
  35. end
  36. function getY()
  37.   return y
  38. end
  39. function getZ()
  40.   return z
  41. end
  42. function getDir()
  43.   return dir
  44. end
  45. function reset()
  46.   x,y,z,dir=0,0,0,0
  47. end
  48. function setFuelSlot(s)
  49.   fuelSlot=s
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement