lipe123

Cactus code

Oct 21st, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | Source Code | 0 0
  1. import Common
  2.  
  3. worldsize = get_world_size()
  4.  
  5. def cplant():
  6. #clear()
  7. Common.MoveTo(0,0)
  8. #plant Cactus everywhere
  9. for x in range(worldsize):
  10. for y in range(worldsize):
  11. if get_ground_type() != Grounds.Soil:
  12. till()
  13. if get_entity_type() != Entities.Cactus:
  14. harvest()
  15. plant(Entities.Cactus)
  16. move(East)
  17. move(North)
  18.  
  19. #sort the fuckers
  20. def csort():
  21. worldsize = get_world_size()
  22. #Sort rows
  23. Common.MoveTo(0,0)
  24. replacelist = []
  25. for y in range(worldsize):
  26. sorted = worldsize-1
  27. finalswap = worldsize-1
  28. while sorted != 0:
  29. move(East)
  30. curx = get_pos_x()
  31. if measure() < measure(West) and curx > 0:
  32. swap(West)
  33. sorted = worldsize-1
  34. replacelist.append(curx)
  35. else:
  36. sorted -= 1
  37. #done with swaps, get the new last position and reset list
  38. if curx >= finalswap:
  39. if len(replacelist) > 0:
  40. finalswap = max(replacelist)
  41. replacelist = []
  42. Common.MoveTo(0,get_pos_y())
  43. else: #its sorted now next list
  44. break
  45. #first time end of row reached
  46. if get_pos_x() == worldsize-1:
  47. if len(replacelist) > 0:
  48. quick_print(max(replacelist))
  49. finalswap = max(replacelist)
  50. replacelist = []
  51. else:
  52. finalswap = curx
  53. move(North)
  54. Common.MoveTo(0,get_pos_y())
  55. replacelist = []
  56.  
  57. #Sort columns
  58. Common.MoveTo(0,0)
  59. replacelist = []
  60. for y in range(worldsize):
  61. sorted = worldsize-1
  62. finalswap = worldsize-1
  63. while sorted != 0:
  64. move(North)
  65. cury = get_pos_y()
  66. if measure() < measure(South) and curx > 0:
  67. swap(South)
  68. sorted = worldsize-1
  69. replacelist.append(cury)
  70. else:
  71. sorted -= 1
  72. #done with swaps, get the new last position and reset list
  73. if cury >= finalswap:
  74. if len(replacelist) > 0:
  75. finalswap = max(replacelist)
  76. replacelist = []
  77. Common.MoveTo(get_pos_x(),0)
  78. else: #its sorted now next list
  79. break
  80. #first time end of row reached
  81. if get_pos_y() == worldsize-1:
  82. if len(replacelist) > 0:
  83. quick_print(max(replacelist))
  84. finalswap = max(replacelist)
  85. replacelist = []
  86. else:
  87. finalswap = curx
  88. move(East)
  89. Common.MoveTo(get_pos_x(),0)
  90. replacelist = []
  91.  
  92. #Harvest em all
  93. def charvest():
  94. worldsize = get_world_size()
  95. Common.MoveTo(worldsize-1,worldsize-1)
  96. harvest()
  97.  
  98. #***************MULTI CODE!!!!*****
  99.  
  100. def cplantMulti():
  101. #plant a row of Cactus
  102. for x in range(worldsize):
  103. if get_ground_type() != Grounds.Soil:
  104. till()
  105. if get_entity_type() != Entities.Cactus:
  106. harvest()
  107. plant(Entities.Cactus)
  108. move(East)
  109.  
  110.  
  111. #sort row multi
  112. def MultiRowSort():
  113. worldsize = get_world_size()
  114. #Sort rows
  115. replacelist = []
  116. sorted = worldsize-1
  117. finalswap = worldsize-1
  118. while sorted != 0:
  119. move(East)
  120. curx = get_pos_x()
  121. if measure() < measure(West) and curx > 0:
  122. swap(West)
  123. sorted = worldsize-1
  124. replacelist.append(curx)
  125. else:
  126. sorted -= 1
  127. #done with swaps, get the new last position and reset list
  128. if curx >= finalswap:
  129. if len(replacelist) > 0:
  130. finalswap = max(replacelist)
  131. replacelist = []
  132. Common.MoveTo(0,get_pos_y())
  133. else: #its sorted now next list
  134. break
  135. #first time end of row reached
  136. if get_pos_x() == worldsize-1:
  137. if len(replacelist) > 0:
  138. #quick_print(max(replacelist))
  139. finalswap = max(replacelist)
  140. replacelist = []
  141. else:
  142. finalswap = curx
  143.  
  144. def MultiColSort():
  145. worldsize = get_world_size()
  146. #Sort rows
  147. replacelist = []
  148. sorted = worldsize-1
  149. finalswap = worldsize-1
  150. while sorted != 0:
  151. move(North)
  152. cury = get_pos_y()
  153. if measure() < measure(South) and cury > 0:
  154. swap(South)
  155. sorted = worldsize-1
  156. replacelist.append(cury)
  157. else:
  158. sorted -= 1
  159. #done with swaps, get the new last position and reset list
  160. if cury >= finalswap:
  161. if len(replacelist) > 0:
  162. finalswap = max(replacelist)
  163. replacelist = []
  164. Common.MoveTo(get_pos_x(),0)
  165. else: #its sorted now next list
  166. break
  167. #first time end of row reached
  168. if get_pos_y() == worldsize-1:
  169. if len(replacelist) > 0:
  170. #quick_print(max(replacelist))
  171. finalswap = max(replacelist)
  172. replacelist = []
  173. else:
  174. finalswap = cury
  175.  
  176.  
  177. def doCactus(size):
  178. #set custom size as needed
  179. if get_world_size() != size:
  180. set_world_size(size)
  181.  
  182. Common.MoveTo(0,0)
  183.  
  184. if num_unlocked(Unlocks.Megafarm) > 0:
  185. #multi plant
  186. for y in range(size):
  187. if num_drones() < max_drones():
  188. spawn_drone(cplantMulti)
  189. else:
  190. cplantMulti()
  191. move(North)
  192.  
  193. #Multi Sort
  194. #row
  195. drones = []
  196. Common.MoveTo(0,0)
  197. while get_pos_y() < size-1:
  198. if num_drones() < max_drones():
  199. newdrone = spawn_drone(MultiRowSort)
  200. drones.append(newdrone)
  201. move(North)
  202. #else:
  203. # MultiRowSort()
  204. for drone in drones:
  205. if has_finished(drone):
  206. drones.remove(drone)
  207.  
  208. #sometimes the last row is missed
  209. MultiRowSort()
  210. for drone in drones:
  211. wait_for(drone)
  212.  
  213.  
  214. #Columns
  215. Common.MoveTo(0,0)
  216. drones = []
  217. while get_pos_x() < size-1:
  218. if num_drones() < max_drones():
  219. newdrone = spawn_drone(MultiColSort)
  220. drones.append(newdrone)
  221. move(East)
  222. #else:
  223. #MultiColSort()
  224. for drone in drones:
  225. if has_finished(drone):
  226. drones.remove(drone)
  227.  
  228. MultiColSort()
  229. for drone in drones:
  230. wait_for(drone)
  231.  
  232.  
  233. #sort complete?!
  234. charvest()
  235.  
  236. #Single drone code
  237. else:
  238. cplant()
  239. csort()
  240. charvest()
Advertisement
Add Comment
Please, Sign In to add comment