Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CropBotField.txt
- log("Harvesting a field");
- // ========================================================================================
- // This script will harvest, repair, and then replant a crop field.
- //
- // ========================================================================================
- &do_repairing = $$[1];
- &repair_tool = $$[2];
- log(%&do_repairing%);
- &do_harvesting = $$[3];
- &harvest_tool = $$[4];
- log(%&do_harvesting%);
- &do_planting = $$[5];
- &replant_crop = $$[6];
- log(%&do_planting%);
- @&meesabot_heading_direction = $$[7];
- #m = $$[8];
- &stepping_direction = $$[9];
- #n = $$[10];
- &do_checkinv = $$[11];
- &deposit_crop = $$[12];
- #chest_x = $$[13];
- #chest_z = $$[14];
- // ========================================================================================
- // Pre-computations
- // ========================================================================================
- #start_x = %XPOS%;
- #start_z = %ZPOS%;
- #walk = #m - 1;
- #num_loops = #n;
- // ========================================================================================
- // Main loop that works on one line per iteration
- // ========================================================================================
- for(#linenum, 1, %#num_loops%);
- // ========================================================================================
- // Harvesting
- // ========================================================================================
- if(%&do_harvesting% = "true");
- log(harvesting);
- unset(@querycropstatus_complete);
- exec(QueryCropStatus.txt,"querycropstatus","%@&meesabot_heading_direction%","35");
- do; wait; until(@querycropstatus_complete); unset(@querycropstatus_complete);
- if(%@&crop_status% = "ready");
- //pick(%&harvest_tool%);
- log(harvesting2);
- slot(1);
- exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%", "attack");
- do; wait(); until(@processline_complete); unset(@processline_complete);
- exec(FlipDirection.txt, "flipdirection);
- do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
- endif;
- endif;
- // ========================================================================================
- // Repairing
- // ========================================================================================
- if(%&do_repairing% = "true");
- //pick(%&repair_tool%);
- slot(3);
- exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%","use");
- do; wait(); until(@processline_complete); unset(@processline_complete);
- exec(FlipDirection.txt, "flipdirection");
- do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
- endif;
- // ========================================================================================
- // Planting
- // ========================================================================================
- if(%&do_planting% = "true");
- pick(%&replant_crop%);
- exec(ProcessLine.txt, "processline", "%@&meesabot_heading_direction%", "85", "%#walk%","use");
- do; wait(); until(@processline_complete); unset(@processline_complete);
- exec(FlipDirection.txt, "flipdirection");
- do; wait(); until(@flipdirection_complete); unset(@flipdirection_complete);
- endif;
- // ========================================================================================
- // Deposit crops
- // ========================================================================================
- if(%&do_checkinv% = "true");
- //Looks at inventory to see if a good amount has been filled.
- //If so, returns to start, dumps things in chest, returns to
- //where it left off.
- press(e);
- wait(250ms);
- getslotitem(26,&item,#num);
- press(e);
- wait(250ms);
- if(%&item% != "air");
- // Save current location
- #return_x = %XPOS%;
- #return_z = %ZPOS%;
- // Move to center column
- exec(WalkToX.txt,"walktox", %#chest_x%);
- do; wait; until(@walktox_complete); unset(@walktox_complete);
- // Move inside the building
- exec(WalkToZ.txt,"walktoz", %#chest_z%);
- do; wait; until(@walktoz_complete); unset(@walktoz_complete);
- log("Depositing %&deposit_crop% into storage chest.");
- look(180,235);
- wait(250ms);
- exec(EmptyItemToDoubleChest.txt,"emptyitemtodoublechest","%&deposit_crop%");
- do; wait; until(@emptyitemtodoublechest_complete); unset(@emptyitemtodoublechest_complete);
- log("Moving back to saved location.");
- // Move back to saved z
- exec(WalkToZ.txt,"walktoz",%#return_z%);
- do; wait; until(@walktoz_complete); unset(@walktoz_complete);
- // Move back to saved x
- exec(WalkToX.txt,"walktox",%#return_x%);
- do; wait; until(@walktox_complete); unset(@walktox_complete);
- endif;
- endif;
- // ========================================================================================
- // Step over
- // ========================================================================================
- if(%#linenum% < %#n%);
- keydown(sneak);
- exec(ProcessLine.txt, "processline", "%&stepping_direction%", "0", "1", "");
- do; wait(); until(@processline_complete); unset(@processline_complete);
- keyup(sneak);
- endif;
- // ========================================================================================
- // End of processing one line
- // ========================================================================================
- next;
- set(@cropbotfield_complete);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement