Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.86 KB | None | 0 0
  1. //TanCo Melonator v1.1
  2. //New feature: slow mode, more reliable
  3. //New feature: automatic anti-iebagi east-west drift correction
  4. //New feature: support for multiple named melon fields eg a field named Thoths
  5. //Just add more elseif sections for more fields
  6.  
  7. //Assumes N/S 2-wide strips of melon stems
  8. //a 2-block gap between the stems for melons to grow
  9. //and chests on the north end of the gap
  10. //Torches placed to keep melons from blocking the north and south ends are recommended
  11.  
  12. //Begin user config
  13.  
  14. &field = "Thoths"
  15. #autologout = 1
  16.  
  17. //set this to a z position the bot will never encounter
  18. //ie don't leave at 0 if your field crosses the Minecraft equator
  19. //strange behavior may result otherwise
  20.  
  21. #zcurr = 0
  22.  
  23. if(&field = "Thoths");
  24. #west = 2448
  25. #north = 12144
  26. #south = 12353
  27. else;
  28. //default field
  29. #west = 2448
  30. #north = 12144
  31. #south = 12353
  32. endif;
  33.  
  34. //0 is fast but has risk of breaking blocks below melons
  35. //1 is slow but reliable, recommended
  36.  
  37. #slowmode = 1
  38.  
  39. //0 disables antistuck feature
  40. //1 attempts to correct positioning errors and logs out on failure
  41.  
  42. #antistuck = 1
  43.  
  44. //end user config
  45.  
  46. //don't touch these unless you know what they do
  47. #forward = 180
  48. #rowwidth = 1
  49. #patience = 1
  50. #wait = 100
  51. &dest = south
  52. #thisrow = %XPOS%
  53. #stuck = 0
  54. #screwiebagi = 0
  55. #totaliebagis = 0
  56. #maxiebagis = 5
  57.  
  58. //log(South is %#south%);
  59.  
  60.  
  61. if(@melonator);
  62. unset(@melonator);
  63. log(Stopping melonator);
  64. keyup(forward);
  65. keyup(sneak);
  66. keyup(left);
  67. keyup(right);
  68. unset(@autochop);
  69. stop("autochop");
  70. break;
  71.  
  72. else;
  73.  
  74. //startup sequence
  75.  
  76. echo(/cto);
  77. //starts an external macro
  78. //this macro continually attacks if @autochop is set
  79. //and sleeps if it is not
  80. //it must be named chop.txt
  81. exec("chop.txt","autochop");
  82. set(@melonator);
  83. log(TanCo melonator enabled);
  84. if(&field = "Thoths");
  85. log(Using config for Thoth's dirtfarm);
  86. else;
  87. log(WARNING: Using config for default field);
  88. endif;
  89.  
  90. //begin main loop
  91.  
  92. do();
  93.  
  94. //Always look forward, sneak, and walk
  95.  
  96. keydown(forward);
  97. keydown(sneak);
  98. look(%#forward%,26);
  99.  
  100. //when slowmode is not set then constantly swing stick
  101. //some risk of breaking blocks below melons unless using slowmode
  102. //if iebagi or another outside force bumps the bot, do not swing until position restored
  103.  
  104. if(!#screwiebagi);
  105. if(!#slowmode);
  106. set(@autochop);
  107. else;
  108.  
  109. //count to #patience if z position does not change while in main loop
  110.  
  111. if(%ZPOS% = #zcurr);
  112. inc(#stuck);
  113. else;
  114. #stuck = 0
  115. endif;
  116.  
  117. #zcurr = %ZPOS%
  118.  
  119. //if z position is not changing then break melon
  120.  
  121. if(#stuck >= #patience);
  122. set(@autochop);
  123. else;
  124. unset(@autochop);
  125. endif;
  126.  
  127. //end position-based melon detection
  128.  
  129. endif;
  130. else;
  131. unset(@autochop);
  132. endif;
  133.  
  134. //Terminal sequence for west end of the field
  135.  
  136. if(%XPOS% >= #west);
  137. log(Reached west end of the field, stopping);
  138. unset(@melonator);
  139. keyup(forward);
  140. keyup(sneak);
  141. keyup(left);
  142. keyup(right);
  143. unset(@autochop);
  144. stop("autochop");
  145. if((#autologout = 1) && (!@melonator));
  146. log(logging out in 5 seconds);
  147. wait(5);
  148. disconnect;
  149. endif;
  150. stop;
  151. endif;
  152.  
  153. //sequence for unexpected east-west drift
  154. //and by unexpected, I mean iebagi teleporting to you
  155. //and bumping your bot so it breaks stems instead of melons
  156. //will wait about 1.5 seconds after a bump before swinging again
  157.  
  158. if(#antistuck = 1);
  159.  
  160. if(%XPOS% > #thisrow);
  161. log(iebagi detected);
  162. set(#screwiebagi,10);
  163. inc(#totaliebagis);
  164. if(&dest = "south");
  165. keyup(left);
  166. keydown(right);
  167. wait(300ms);
  168. elseif(&dest = "north");
  169. keyup(right);
  170. keydown(left);
  171. wait(300ms);
  172. endif;
  173. elseif(%XPOS% < #thisrow);
  174. log(iebagi detected);
  175. set(#screwiebagi,10);
  176. inc(#totaliebagis);
  177. if(&dest = "south");
  178. keyup(right);
  179. keydown(left);
  180. wait(300ms);
  181. elseif(&dest = "north");
  182. keyup(left);
  183. keydown(right);
  184. wait(300ms);
  185. endif;
  186. else;
  187. keyup(left);
  188. keyup(right);
  189. if(#screwiebagi >= 0);
  190. dec(#screwiebagi);
  191. endif;
  192. endif;
  193. //log(Screwiebeagi is %#screwiebagi%);
  194.  
  195. //sequence for being stuck on the edge of a melon
  196. //count for #stuck is controlled by the anti-iebagi sequence
  197.  
  198. if(#stuck > 30);
  199. log(help help I'm stuck);
  200. keydown(left);
  201. wait(300ms);
  202. keyup(left);
  203. keydown(right);
  204. wait(600ms);
  205. keyup(right);
  206. keydown(left);
  207. wait(300ms);
  208. endif;
  209.  
  210. if((#stuck >= 100) || (#totaliebagis > #maxiebagis));
  211. log(ERROR: All attempts to unstick myself have failed);
  212. log(%#stuck%% stuck, %#totaliebagis% iebagis detected);
  213. log(Disconnecting in 5);
  214. unset(@melonator);
  215. log(Stopping melonator);
  216. keyup(forward);
  217. keyup(sneak);
  218. keyup(left);
  219. keyup(right);
  220. unset(@autochop);
  221. stop("autochop");
  222. if(!@melonator);
  223. wait(5);
  224. disconnect;
  225. endif;
  226. endif;
  227.  
  228. //close antistuck sequence
  229.  
  230. endif;
  231.  
  232. //Detect arrival at north end of field
  233.  
  234. if((%ZPOS% = #north) && (&dest = "north"));
  235. unset(@autochop);
  236. log(reached north end of field);
  237. if(#antistuck = 1);
  238. log(I have experienced %#totaliebagis% iebagis this row);
  239. endif;
  240. unset(#totaliebagis);
  241.  
  242.  
  243. //chest melons
  244.  
  245. look(0,35);
  246. keyup(sneak);
  247. wait(%#wait%ms);
  248. wait(%#wait%ms);
  249. key(use);
  250. wait(%#wait%ms);
  251. log(Chesting crops);
  252. for(#forthrow,54,80);
  253. slotclick(%#forthrow%,l,true);
  254. wait(%#wait%ms);
  255. next;
  256. gui();
  257. keydown(sneak);
  258.  
  259. //end chesting sequence
  260.  
  261. //slide to the west
  262.  
  263. #current = %XPOS%
  264. look(270,0);
  265. keydown(forward);
  266. //keydown(sneak);
  267. //log(row width %#rowwidth%);
  268. do();
  269. //log(made it to do in north check);
  270. wait(100ms);
  271. until(%XPOS% = (#current-#rowwidth));
  272. //wait(1);
  273. log(reached next row);
  274. #thisrow = %XPOS%
  275. &dest = south
  276. #forward = 180
  277.  
  278. if(!#slowmode);
  279. set(@autochop);
  280. endif;
  281.  
  282. //Alternates row width
  283.  
  284. if(#rowwidth = 1);
  285. #rowwidth = 3
  286. else;
  287. #rowwidth = 1
  288. endif;
  289.  
  290. //log(row width %#rowwidth%);
  291.  
  292. endif;
  293.  
  294.  
  295. //same but for south end of field
  296. //no chests here
  297.  
  298. if((%ZPOS% = #south) && (&dest = "south"));
  299. unset(@autochop);
  300. log(reached south end of field);
  301. if(#antistuck = 1);
  302. log(I have experienced %#totaliebagis% iebagis this row);
  303. endif;
  304. unset(#totaliebagis);
  305.  
  306. //slide to the west
  307.  
  308. #current = %XPOS%
  309. look(270,0);
  310. keydown(forward);
  311. keydown(sneak);
  312. //log(row width %#rowwidth%);
  313. do();
  314. //log(made it to do in south check);
  315. wait(100ms);
  316. until(%XPOS% = (#current-#rowwidth));
  317. //wait(1);
  318. log(reached next row);
  319. #thisrow = %XPOS%
  320. &dest = north
  321. #forward = 0
  322.  
  323. if(!#slowmode);
  324. set(@autochop);
  325. endif;
  326.  
  327. //Alternates row width
  328.  
  329. if(#rowwidth = 1);
  330. #rowwidth = 3
  331. else;
  332. #rowwidth = 1
  333. endif;
  334.  
  335.  
  336. endif;
  337.  
  338. //check hunger, deactivate axe, eat food if needed, reactivate axe
  339.  
  340. if(%HUNGER% <= 18);
  341. look(0,270);
  342. unset(@autochop);
  343. keyup(forward);
  344. keyup(back);
  345. keyup(left);
  346. keyup(right);
  347. log(Getting hungry. Eating from offhand.);
  348. //slot(%#toolslot%);
  349. do();
  350. key(use);
  351. until(%HUNGER% > 19);
  352. if(!#slowmode);
  353. set(@autochop);
  354. endif;
  355. endif;
  356.  
  357. //Switch to new tool if current tool is about to break
  358. //Always switches to the right
  359.  
  360. if((%DURABILITY% < 5) && (%DURABILITY% > 1));
  361. log(&4Durability low! %DURABILITY%);
  362. inventoryup(1);
  363. endif;
  364.  
  365. //delay for main loop
  366. //100ms is good enough
  367.  
  368. wait(%#wait%ms);
  369.  
  370. //log(made it to end of main loop);
  371.  
  372. while(@melonator);
  373.  
  374. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement