Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TanCo Melonator v1.1
- //New feature: slow mode, more reliable
- //New feature: automatic anti-iebagi east-west drift correction
- //New feature: support for multiple named melon fields eg a field named Thoths
- //Just add more elseif sections for more fields
- //Assumes N/S 2-wide strips of melon stems
- //a 2-block gap between the stems for melons to grow
- //and chests on the north end of the gap
- //Torches placed to keep melons from blocking the north and south ends are recommended
- //Begin user config
- &field = "Thoths"
- #autologout = 1
- //set this to a z position the bot will never encounter
- //ie don't leave at 0 if your field crosses the Minecraft equator
- //strange behavior may result otherwise
- #zcurr = 0
- if(&field = "Thoths");
- #west = 2448
- #north = 12144
- #south = 12353
- else;
- //default field
- #west = 2448
- #north = 12144
- #south = 12353
- endif;
- //0 is fast but has risk of breaking blocks below melons
- //1 is slow but reliable, recommended
- #slowmode = 1
- //0 disables antistuck feature
- //1 attempts to correct positioning errors and logs out on failure
- #antistuck = 1
- //end user config
- //don't touch these unless you know what they do
- #forward = 180
- #rowwidth = 1
- #patience = 1
- #wait = 100
- &dest = south
- #thisrow = %XPOS%
- #stuck = 0
- #screwiebagi = 0
- #totaliebagis = 0
- #maxiebagis = 5
- //log(South is %#south%);
- if(@melonator);
- unset(@melonator);
- log(Stopping melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- break;
- else;
- //startup sequence
- echo(/cto);
- //starts an external macro
- //this macro continually attacks if @autochop is set
- //and sleeps if it is not
- //it must be named chop.txt
- exec("chop.txt","autochop");
- set(@melonator);
- log(TanCo melonator enabled);
- if(&field = "Thoths");
- log(Using config for Thoth's dirtfarm);
- else;
- log(WARNING: Using config for default field);
- endif;
- //begin main loop
- do();
- //Always look forward, sneak, and walk
- keydown(forward);
- keydown(sneak);
- look(%#forward%,26);
- //when slowmode is not set then constantly swing stick
- //some risk of breaking blocks below melons unless using slowmode
- //if iebagi or another outside force bumps the bot, do not swing until position restored
- if(!#screwiebagi);
- if(!#slowmode);
- set(@autochop);
- else;
- //count to #patience if z position does not change while in main loop
- if(%ZPOS% = #zcurr);
- inc(#stuck);
- else;
- #stuck = 0
- endif;
- #zcurr = %ZPOS%
- //if z position is not changing then break melon
- if(#stuck >= #patience);
- set(@autochop);
- else;
- unset(@autochop);
- endif;
- //end position-based melon detection
- endif;
- else;
- unset(@autochop);
- endif;
- //Terminal sequence for west end of the field
- if(%XPOS% >= #west);
- log(Reached west end of the field, stopping);
- unset(@melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- if((#autologout = 1) && (!@melonator));
- log(logging out in 5 seconds);
- wait(5);
- disconnect;
- endif;
- stop;
- endif;
- //sequence for unexpected east-west drift
- //and by unexpected, I mean iebagi teleporting to you
- //and bumping your bot so it breaks stems instead of melons
- //will wait about 1.5 seconds after a bump before swinging again
- if(#antistuck = 1);
- if(%XPOS% > #thisrow);
- log(iebagi detected);
- set(#screwiebagi,10);
- inc(#totaliebagis);
- if(&dest = "south");
- keyup(left);
- keydown(right);
- wait(300ms);
- elseif(&dest = "north");
- keyup(right);
- keydown(left);
- wait(300ms);
- endif;
- elseif(%XPOS% < #thisrow);
- log(iebagi detected);
- set(#screwiebagi,10);
- inc(#totaliebagis);
- if(&dest = "south");
- keyup(right);
- keydown(left);
- wait(300ms);
- elseif(&dest = "north");
- keyup(left);
- keydown(right);
- wait(300ms);
- endif;
- else;
- keyup(left);
- keyup(right);
- if(#screwiebagi >= 0);
- dec(#screwiebagi);
- endif;
- endif;
- //log(Screwiebeagi is %#screwiebagi%);
- //sequence for being stuck on the edge of a melon
- //count for #stuck is controlled by the anti-iebagi sequence
- if(#stuck > 30);
- log(help help I'm stuck);
- keydown(left);
- wait(300ms);
- keyup(left);
- keydown(right);
- wait(600ms);
- keyup(right);
- keydown(left);
- wait(300ms);
- endif;
- if((#stuck >= 100) || (#totaliebagis > #maxiebagis));
- log(ERROR: All attempts to unstick myself have failed);
- log(%#stuck%% stuck, %#totaliebagis% iebagis detected);
- log(Disconnecting in 5);
- unset(@melonator);
- log(Stopping melonator);
- keyup(forward);
- keyup(sneak);
- keyup(left);
- keyup(right);
- unset(@autochop);
- stop("autochop");
- if(!@melonator);
- wait(5);
- disconnect;
- endif;
- endif;
- //close antistuck sequence
- endif;
- //Detect arrival at north end of field
- if((%ZPOS% = #north) && (&dest = "north"));
- unset(@autochop);
- log(reached north end of field);
- if(#antistuck = 1);
- log(I have experienced %#totaliebagis% iebagis this row);
- endif;
- unset(#totaliebagis);
- //chest melons
- look(0,35);
- keyup(sneak);
- wait(%#wait%ms);
- wait(%#wait%ms);
- key(use);
- wait(%#wait%ms);
- log(Chesting crops);
- for(#forthrow,54,80);
- slotclick(%#forthrow%,l,true);
- wait(%#wait%ms);
- next;
- gui();
- keydown(sneak);
- //end chesting sequence
- //slide to the west
- #current = %XPOS%
- look(270,0);
- keydown(forward);
- //keydown(sneak);
- //log(row width %#rowwidth%);
- do();
- //log(made it to do in north check);
- wait(100ms);
- until(%XPOS% = (#current-#rowwidth));
- //wait(1);
- log(reached next row);
- #thisrow = %XPOS%
- &dest = south
- #forward = 180
- if(!#slowmode);
- set(@autochop);
- endif;
- //Alternates row width
- if(#rowwidth = 1);
- #rowwidth = 3
- else;
- #rowwidth = 1
- endif;
- //log(row width %#rowwidth%);
- endif;
- //same but for south end of field
- //no chests here
- if((%ZPOS% = #south) && (&dest = "south"));
- unset(@autochop);
- log(reached south end of field);
- if(#antistuck = 1);
- log(I have experienced %#totaliebagis% iebagis this row);
- endif;
- unset(#totaliebagis);
- //slide to the west
- #current = %XPOS%
- look(270,0);
- keydown(forward);
- keydown(sneak);
- //log(row width %#rowwidth%);
- do();
- //log(made it to do in south check);
- wait(100ms);
- until(%XPOS% = (#current-#rowwidth));
- //wait(1);
- log(reached next row);
- #thisrow = %XPOS%
- &dest = north
- #forward = 0
- if(!#slowmode);
- set(@autochop);
- endif;
- //Alternates row width
- if(#rowwidth = 1);
- #rowwidth = 3
- else;
- #rowwidth = 1
- endif;
- endif;
- //check hunger, deactivate axe, eat food if needed, reactivate axe
- if(%HUNGER% <= 18);
- look(0,270);
- unset(@autochop);
- keyup(forward);
- keyup(back);
- keyup(left);
- keyup(right);
- log(Getting hungry. Eating from offhand.);
- //slot(%#toolslot%);
- do();
- key(use);
- until(%HUNGER% > 19);
- if(!#slowmode);
- set(@autochop);
- endif;
- endif;
- //Switch to new tool if current tool is about to break
- //Always switches to the right
- if((%DURABILITY% < 5) && (%DURABILITY% > 1));
- log(&4Durability low! %DURABILITY%);
- inventoryup(1);
- endif;
- //delay for main loop
- //100ms is good enough
- wait(%#wait%ms);
- //log(made it to end of main loop);
- while(@melonator);
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement