Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. // CropBotField.txt
  2.  
  3. log("Harvesting a field");
  4.  
  5. // ========================================================================================
  6. // This script will harvest, repair, and then replant a crop field.
  7. //
  8. // ========================================================================================
  9. &do_repairing = $$[1];
  10. &repair_tool = $$[2];
  11. log(%&do_repairing%);
  12.  
  13. &do_harvesting = $$[3];
  14. &harvest_tool = $$[4];
  15. log(%&do_harvesting%);
  16.  
  17. &do_planting = $$[5];
  18. &replant_crop = $$[6];
  19. log(%&do_planting%);
  20.  
  21. @&meesabot_heading_direction = $$[7];
  22. #m = $$[8];
  23.  
  24. &stepping_direction = $$[9];
  25. #n = $$[10];
  26.  
  27. &do_checkinv = $$[11];
  28. &deposit_crop = $$[12];
  29. #chest_x = $$[13];
  30. #chest_z = $$[14];
  31.  
  32. // ========================================================================================
  33. // Pre-computations
  34. // ========================================================================================
  35. #start_x = %XPOS%;
  36. #start_z = %ZPOS%;
  37.  
  38. #walk = #m - 1;
  39. #num_loops = #n;
  40.  
  41.  
  42. // ========================================================================================
  43. // Main loop that works on one line per iteration
  44. // ========================================================================================
  45. for(#linenum, 1, %#num_loops%);
  46.  
  47. // ========================================================================================
  48. // Harvesting
  49. // ========================================================================================
  50. if(%&do_harvesting% = "true");
  51. log(harvesting);
  52. unset(@querycropstatus_complete);
  53. exec(QueryCropStatus.txt,"querycropstatus","%@&meesabot_heading_direction%","35");
  54. do; wait; until(@querycropstatus_complete); unset(@querycropstatus_complete);
  55. if(%@&crop_status% = "ready");
  56. //pick(%&harvest_tool%);
  57. log(harvesting2);
  58. slot(1);
  59. exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%", "attack");
  60. do; wait(); until(@processline_complete); unset(@processline_complete);
  61.  
  62. exec(FlipDirection.txt, "flipdirection);
  63. do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
  64. endif;
  65. endif;
  66.  
  67.  
  68.  
  69.  
  70. // ========================================================================================
  71. // Repairing
  72. // ========================================================================================
  73. if(%&do_repairing% = "true");
  74. //pick(%&repair_tool%);
  75. slot(3);
  76. exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%","use");
  77. do; wait(); until(@processline_complete); unset(@processline_complete);
  78.  
  79. exec(FlipDirection.txt, "flipdirection");
  80. do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
  81. endif;
  82.  
  83.  
  84.  
  85.  
  86. // ========================================================================================
  87. // Planting
  88. // ========================================================================================
  89. if(%&do_planting% = "true");
  90. pick(%&replant_crop%);
  91. exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%","use");
  92. do; wait(); until(@processline_complete); unset(@processline_complete);
  93.  
  94. exec(FlipDirection.txt, "flipdirection");
  95. do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
  96. endif;
  97.  
  98.  
  99. // ========================================================================================
  100. // Deposit crops
  101. // ========================================================================================
  102.  
  103. if(%&do_checkinv% = "true");
  104. //Looks at inventory to see if a good amount has been filled.
  105. //If so, returns to start, dumps things in chest, returns to
  106. //where it left off.
  107. press(e);
  108. wait(250ms);
  109. getslotitem(26,&item,#num);
  110. press(e);
  111. wait(250ms);
  112. if(%&item% != "air");
  113. // Save current location
  114. #return_x = %XPOS%;
  115. #return_z = %ZPOS%;
  116. // Move to center column
  117. exec(WalkToX.txt,"walktox", %#chest_x%);
  118. do; wait; until(@walktox_complete); unset(@walktox_complete);
  119.  
  120. // Move inside the building
  121. exec(WalkToZ.txt,"walktoz", %#chest_z%);
  122. do; wait; until(@walktoz_complete); unset(@walktoz_complete);
  123.  
  124. log("Depositing %&deposit_crop% into storage chest.");
  125. look(180,235);
  126. wait(250ms);
  127. exec(EmptyItemToDoubleChest.txt,"emptyitemtodoublechest","%&deposit_crop%");
  128. do; wait; until(@emptyitemtodoublechest_complete); unset(@emptyitemtodoublechest_complete);
  129.  
  130. log("Moving back to saved location.");
  131. // Move back to saved z
  132. exec(WalkToZ.txt,"walktoz",%#return_z%);
  133. do; wait; until(@walktoz_complete); unset(@walktoz_complete);
  134.  
  135. // Move back to saved x
  136. exec(WalkToX.txt,"walktox",%#return_x%);
  137. do; wait; until(@walktox_complete); unset(@walktox_complete);
  138.  
  139. endif;
  140. endif;
  141.  
  142.  
  143. // ========================================================================================
  144. // Step over
  145. // ========================================================================================
  146. if(%#linenum% < %#n%);
  147. keydown(sneak);
  148. exec(ProcessLine.txt, "processline", "%&stepping_direction%", "0", "1", "");
  149. do; wait(); until(@processline_complete); unset(@processline_complete);
  150. keyup(sneak);
  151. endif;
  152.  
  153.  
  154. // ========================================================================================
  155. // End of processing one line
  156. // ========================================================================================
  157. next;
  158.  
  159. set(@cropbotfield_complete);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement