Advertisement
Guest User

move_to.txt

a guest
Oct 16th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. unset(@obstructed);
  2. unset(@arrived);
  3. unset(@dig_recommended);
  4. #yaw = 0;
  5. #oldxpos=XPOS;
  6. #oldzpos=ZPOS;
  7. #tick = TOTALTICKS;
  8. #pitch=45;
  9. #large_m_timeout=1200;
  10. #short_m_timeout=600;
  11.  
  12. log("attempting to move to $$[1],$$[2]");
  13.  
  14. calcyawto($$[1],$$[2],#yaw);
  15. inc(#yaw,180);
  16. look(%#yaw%,%#pitch%);
  17. keydown(forward);
  18.  
  19. do;
  20. calcyawto($$[1],$$[2],#yaw);
  21. if((YAW!=#yaw) || (PITCH!=#pitch))
  22. inc(#yaw,180);
  23. look(%#yaw%,%#pitch%);
  24. endif;
  25. if((XPOS==$$[1])&&(ZPOS==$$[2]));
  26. set(@arrived);
  27. endif;
  28.  
  29. //each time we change x or z.
  30. if((XPOS!=#oldxpos)||(ZPOS!=#oldzpos));
  31. #tick=TOTALTICKS;
  32. #oldxpos=XPOS;
  33. #oldzpos=ZPOS;
  34. endif;
  35.  
  36. #tickdiff=TOTALTICKS-#tick;
  37.  
  38. //if we've not moved in a bit signal that we might need to dig out way out.
  39. if(#tickdiff>#short_m_timeout);
  40. set(@dig_recommended);
  41. endif;
  42.  
  43. //if we've not moved in a while give up trying.
  44. if(#tickdiff>#large_m_timeout);
  45. set(@obstructed);
  46. log("Obstructed.");
  47. endif;
  48.  
  49. until((@arrived||@obstructed)||HEALTH<0);
  50. keyup(forward);
  51. log("done move_to");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement