Advertisement
Guest User

TanCo Melonator 1.4

a guest
Jul 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.03 KB | None | 0 0
  1.  
  2.  
  3. //TanCo Melonator
  4. log(v1.4);
  5. //v1.4
  6. //No longer ever tries to use default orientation values, which was silly
  7. //v1.3.4
  8. //Axe durability config now implemented correctly
  9. //v1.3.3
  10. //Better suppport for silk touch axes, won't break chests as much
  11. //Chests now must be placed one block higher
  12. //Config for durability threshold to switch to next tool, raised default to 12
  13. //Axes should be consecutive on hotbar, optionally followed by a stick to their right
  14. //v1.3.2
  15. //fall protection
  16. //v1.3.1
  17. //Hotfix for default row width
  18. //Announces version on start
  19. //v1.3
  20. //Audio alert on emptying into chest
  21. //Fix for start from any position
  22. //v1.2
  23. //New feature: slow mode, more reliable
  24. //New feature: automatic anti-iebagi east-west drift correction
  25. //New feature: support for multiple named melon fields eg a field named Thoths
  26. //Just add more elseif sections for more fields
  27.  
  28. //Assumes N/S 2-wide strips of melon stems
  29. //a 2-block gap between the stems for melons to grow
  30. //and chests on the north end of the gap
  31. //Torches placed to keep melons from blocking the north and south ends are recommended
  32.  
  33. //Begin user config
  34.  
  35. &field = "Thoths"
  36. #autologout = 1
  37.  
  38. //set this to a z position the bot will never encounter
  39. //ie don't leave at 0 if your field crosses the Minecraft equator
  40. //strange behavior may result otherwise
  41.  
  42. #zcurr = 0
  43.  
  44. if(&field = "Thoths");
  45. #west = -2448
  46. #north = 12144
  47. #south = 12353
  48. else;
  49. //default field
  50. #west = -2448
  51. #north = 12144
  52. #south = 12353
  53. endif;
  54.  
  55. //0 is fast but has risk of breaking blocks below melons
  56. //1 is slow but reliable, recommended
  57. #slowmode = 1
  58.  
  59. //0 disables antistuck feature
  60. //1 attempts to correct positioning errors and logs out on failure
  61. #antistuck = 1
  62.  
  63. //panic if you've been moved out of your row too often, default 5, only works with #antistuck
  64. #maxiebagis = 5
  65.  
  66. //default "diamond_axe" ideally with silk touch, not mandatory
  67. &tool = "diamond_axe"
  68. //durability threshold for switching to next axe to prevent breakage, default 12
  69. #toolduramin = 12
  70.  
  71. //end user config
  72.  
  73. //don't touch these unless you know what they do
  74. #forward = 180
  75. #rowwidth = 1
  76. #patience = 1
  77. #wait = 100
  78. &dest = south
  79. #thisrow = %XPOS%
  80. #stuck = 0
  81. #screwiebagi = 0
  82. #totaliebagis = 0
  83. #rownumber = 0
  84. #ystart = %YPOS%
  85. #toolslot = 1
  86.  
  87.  
  88.  
  89. //log(South is %#south%);
  90.  
  91.  
  92. if(@melonator);
  93. unset(@melonator);
  94. log(Stopping melonator);
  95. keyup(forward);
  96. keyup(sneak);
  97. keyup(left);
  98. keyup(right);
  99. unset(@autochop);
  100. stop("autochop");
  101. break;
  102.  
  103. else;
  104.  
  105. //startup sequence
  106.  
  107. //turns off bypass mode on Citadel servers
  108. echo(/cto);
  109.  
  110. //select tool ie diamond_axe
  111. //do nothing if tool not present
  112. getslot(%&tool%,#toolslot);
  113. if((#toolslot < 10) && (#toolslot > -1));
  114. slot(%#toolslot%);
  115. log(Selecting %&tool% in slot %#toolslot%);
  116. else;
  117. log(Did not find %&tool% on hotbar, this is fine);
  118. endif;
  119.  
  120. //starts an external macro
  121. //this macro continually attacks if @autochop is set
  122. //and sleeps if it is not
  123. //it must be named chop.txt
  124. exec("chop.txt","autochop");
  125. set(@melonator);
  126. log(TanCo melonator enabled);
  127. if(&field = "Thoths");
  128. log(Using config for Thoth's dirtfarm);
  129. else;
  130. log(WARNING: Using config for default field);
  131. endif;
  132.  
  133. //startup check, where are we in the field?
  134.  
  135. log(I am starting from the middle of the field);
  136. log(Beginning overcomplicated subroutine to find my place);
  137. #rowcoords = (%#west%+1)
  138. #rowwidth = 1
  139. //log(West is %#west% lasttree is %#lasttree%);
  140.  
  141. //count down row numbers from the west
  142.  
  143. do(99);
  144. inc(#rownumber);
  145. inc(#rowcoords,%#rowwidth%);
  146. if(#rowwidth = 1);
  147. set(#rowwidth,3);
  148. else;
  149. set(#rowwidth,1);
  150. endif;
  151. until(#rowcoords > %XPOS%);
  152. log(I am in row number %#rownumber%);
  153. loop;
  154.  
  155. //brutal test for divisibility by 2
  156.  
  157. #evenorodd = (%#rownumber% / 2)
  158. if((#evenorodd * 2) = %#rownumber%);
  159. log(This row is even);
  160. set(#evenrow,1);
  161. else;
  162. log(This row is odd);
  163. set(#evenrow,0);
  164. endif;
  165.  
  166. //knowing the row is odd or even, set row width and facing direction
  167. if(#evenrow = 1);
  168. #forward = 180
  169. &dest = south
  170. #rowwidth = 1
  171. else;
  172. #forward = 0
  173. &dest = north
  174. #rowwidth = 3
  175. endif;
  176.  
  177.  
  178. //begin main loop
  179.  
  180. do();
  181.  
  182. //Always sneak, and walk
  183.  
  184. keydown(forward);
  185. keydown(sneak);
  186.  
  187.  
  188. //when slowmode is not set then constantly swing stick
  189. //some risk of breaking blocks below melons unless using slowmode
  190. //if iebagi or another outside force bumps the bot, do not swing until position restored
  191.  
  192. if(!#screwiebagi);
  193. if(!#slowmode);
  194. set(@autochop);
  195. else;
  196.  
  197. //count to #patience if z position does not change while in main loop
  198.  
  199. if(%ZPOS% = #zcurr);
  200. inc(#stuck);
  201. else;
  202. #stuck = 0
  203. endif;
  204.  
  205. #zcurr = %ZPOS%
  206.  
  207. //if z position is not changing then break melon
  208.  
  209. if(#stuck >= #patience);
  210. set(@autochop);
  211. else;
  212. unset(@autochop);
  213. endif;
  214.  
  215. //end position-based melon detection
  216.  
  217. endif;
  218. else;
  219. unset(@autochop);
  220. endif;
  221.  
  222. //Terminal sequence for west end of the field
  223.  
  224. if(%XPOS% <= #west);
  225. log(Reached west end of the field, stopping);
  226. unset(@melonator);
  227. keyup(forward);
  228. keyup(sneak);
  229. keyup(left);
  230. keyup(right);
  231. unset(@autochop);
  232. stop("autochop");
  233. if((#autologout = 1) && (!@melonator));
  234. log(logging out in 5 seconds);
  235. wait(5);
  236. disconnect;
  237. endif;
  238. stop;
  239. endif;
  240.  
  241. //sequence for unexpected east-west drift
  242. //and by unexpected, I mean iebagi teleporting to you
  243. //and bumping your bot so it breaks stems instead of melons
  244. //will wait about 1.5 seconds after a bump before swinging again
  245.  
  246. if(#antistuck = 1);
  247.  
  248. if(%XPOS% > #thisrow);
  249. log(iebagi detected);
  250. set(#screwiebagi,10);
  251. inc(#totaliebagis);
  252. if(&dest = "south");
  253. keyup(left);
  254. keydown(right);
  255. wait(300ms);
  256. elseif(&dest = "north");
  257. keyup(right);
  258. keydown(left);
  259. wait(300ms);
  260. endif;
  261. elseif(%XPOS% < #thisrow);
  262. log(iebagi detected);
  263. set(#screwiebagi,10);
  264. inc(#totaliebagis);
  265. if(&dest = "south");
  266. keyup(right);
  267. keydown(left);
  268. wait(300ms);
  269. elseif(&dest = "north");
  270. keyup(left);
  271. keydown(right);
  272. wait(300ms);
  273. endif;
  274. else;
  275. keyup(left);
  276. keyup(right);
  277. if(#screwiebagi >= 0);
  278. dec(#screwiebagi);
  279. endif;
  280. endif;
  281. //log(Screwiebeagi is %#screwiebagi%);
  282.  
  283. //sequence for being stuck on the edge of a melon
  284. //count for #stuck is controlled by the anti-iebagi sequence
  285.  
  286. if(#stuck > 30);
  287. log(help help I'm stuck);
  288. keydown(left);
  289. wait(300ms);
  290. keyup(left);
  291. keydown(right);
  292. wait(600ms);
  293. keyup(right);
  294. keydown(left);
  295. wait(300ms);
  296. endif;
  297.  
  298. if((#stuck >= 100) || (#totaliebagis > #maxiebagis));
  299. log(ERROR: All attempts to unstick myself have failed);
  300. log(%#stuck%% stuck, %#totaliebagis% iebagis detected);
  301. log(Disconnecting in 5);
  302. unset(@melonator);
  303. log(Stopping melonator);
  304. keyup(forward);
  305. keyup(sneak);
  306. keyup(left);
  307. keyup(right);
  308. unset(@autochop);
  309. stop("autochop");
  310. if(!@melonator);
  311. wait(5);
  312. disconnect;
  313. endif;
  314. endif;
  315.  
  316. //close antistuck sequence
  317.  
  318. endif;
  319.  
  320. //Detect near north end of field facing north, look at feet
  321. //Makes it less likely to break melon chests by accident
  322. if((%ZPOS% = (#north + 1)) && (&dest = "north"));
  323. //log(Getting close. Looking at feet.);
  324. look(%#forward%,65);
  325. else;
  326. look(%#forward%,26);
  327. endif;
  328.  
  329. //Detect arrival at north end of field
  330.  
  331. if((%ZPOS% = #north) && (&dest = "north"));
  332. unset(@autochop);
  333. log(reached north end of field);
  334. if(#antistuck = 1);
  335. log(I have experienced %#totaliebagis% iebagis this row);
  336. endif;
  337. unset(#totaliebagis);
  338.  
  339.  
  340. //chest melons
  341.  
  342. playsound(entity.enderdragon.death);
  343. keyup(sneak);
  344. wait(%#wait%ms);
  345. look(0,340);
  346. wait(%#wait%ms);
  347. key(use);
  348. wait(%#wait%ms);
  349. log(Chesting crops);
  350. for(#forthrow,54,80);
  351. slotclick(%#forthrow%,l,true);
  352. wait(%#wait%ms);
  353. next;
  354. gui();
  355. keydown(sneak);
  356.  
  357. //end chesting sequence
  358.  
  359. //slide to the west
  360.  
  361. #current = %XPOS%
  362. look(270,0);
  363. keydown(forward);
  364. //keydown(sneak);
  365. //log(row width %#rowwidth%);
  366. do();
  367. //log(made it to do in north check);
  368. wait(100ms);
  369. until(%XPOS% = (#current-#rowwidth));
  370. //wait(1);
  371. log(reached next row);
  372. #thisrow = %XPOS%
  373. &dest = south
  374. #forward = 180
  375.  
  376. if(!#slowmode);
  377. set(@autochop);
  378. endif;
  379.  
  380. //Alternates row width
  381.  
  382. if(#rowwidth = 1);
  383. #rowwidth = 3
  384. else;
  385. #rowwidth = 1
  386. endif;
  387.  
  388. //log(row width %#rowwidth%);
  389.  
  390. endif;
  391.  
  392.  
  393. //same but for south end of field
  394. //no chests here
  395.  
  396. if((%ZPOS% = #south) && (&dest = "south"));
  397. unset(@autochop);
  398. log(reached south end of field);
  399. if(#antistuck = 1);
  400. log(I have experienced %#totaliebagis% iebagis this row);
  401. endif;
  402. unset(#totaliebagis);
  403.  
  404. //slide to the west
  405.  
  406. #current = %XPOS%
  407. look(270,0);
  408. keydown(forward);
  409. keydown(sneak);
  410. //log(row width %#rowwidth%);
  411. do();
  412. //log(made it to do in south check);
  413. wait(100ms);
  414. until(%XPOS% = (#current-#rowwidth));
  415. //wait(1);
  416. log(reached next row);
  417. #thisrow = %XPOS%
  418. &dest = north
  419. #forward = 0
  420.  
  421. if(!#slowmode);
  422. set(@autochop);
  423. endif;
  424.  
  425. //Alternates row width
  426.  
  427. if(#rowwidth = 1);
  428. #rowwidth = 3
  429. else;
  430. #rowwidth = 1
  431. endif;
  432.  
  433.  
  434. endif;
  435.  
  436. //check hunger, deactivate axe, eat food if needed, reactivate axe
  437.  
  438. if(%HUNGER% <= 18);
  439. look(0,270);
  440. unset(@autochop);
  441. keyup(forward);
  442. keyup(back);
  443. keyup(left);
  444. keyup(right);
  445. log(Getting hungry. Eating from offhand.);
  446. //slot(%#toolslot%);
  447. do();
  448. key(use);
  449. until(%HUNGER% > 19);
  450. if(!#slowmode);
  451. set(@autochop);
  452. endif;
  453. endif;
  454.  
  455. //fall protection
  456. if(%YPOS% < (#ystart - 1));
  457. log(Help help, I've fallen and I can't get up.);
  458. unset(@autochop);
  459. unset(@melonator);
  460. disconnect;
  461. endif;
  462.  
  463. //Switch to new tool if current tool is about to break
  464. //Always switches to the right
  465.  
  466. if((%DURABILITY% < #toolduramin) && (%DURABILITY% > 1));
  467. log(&4Durability low! %DURABILITY%);
  468. inventoryup(1);
  469. endif;
  470.  
  471. //delay for main loop
  472. //100ms is good enough
  473.  
  474. wait(%#wait%ms);
  475.  
  476. //log(made it to end of main loop);
  477.  
  478. while(@melonator);
  479.  
  480. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement