Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Common
- worldsize = get_world_size()
- def cplant():
- #clear()
- Common.MoveTo(0,0)
- #plant Cactus everywhere
- for x in range(worldsize):
- for y in range(worldsize):
- if get_ground_type() != Grounds.Soil:
- till()
- if get_entity_type() != Entities.Cactus:
- harvest()
- plant(Entities.Cactus)
- move(East)
- move(North)
- #sort the fuckers
- def csort():
- worldsize = get_world_size()
- #Sort rows
- Common.MoveTo(0,0)
- replacelist = []
- for y in range(worldsize):
- sorted = worldsize-1
- finalswap = worldsize-1
- while sorted != 0:
- move(East)
- curx = get_pos_x()
- if measure() < measure(West) and curx > 0:
- swap(West)
- sorted = worldsize-1
- replacelist.append(curx)
- else:
- sorted -= 1
- #done with swaps, get the new last position and reset list
- if curx >= finalswap:
- if len(replacelist) > 0:
- finalswap = max(replacelist)
- replacelist = []
- Common.MoveTo(0,get_pos_y())
- else: #its sorted now next list
- break
- #first time end of row reached
- if get_pos_x() == worldsize-1:
- if len(replacelist) > 0:
- quick_print(max(replacelist))
- finalswap = max(replacelist)
- replacelist = []
- else:
- finalswap = curx
- move(North)
- Common.MoveTo(0,get_pos_y())
- replacelist = []
- #Sort columns
- Common.MoveTo(0,0)
- replacelist = []
- for y in range(worldsize):
- sorted = worldsize-1
- finalswap = worldsize-1
- while sorted != 0:
- move(North)
- cury = get_pos_y()
- if measure() < measure(South) and curx > 0:
- swap(South)
- sorted = worldsize-1
- replacelist.append(cury)
- else:
- sorted -= 1
- #done with swaps, get the new last position and reset list
- if cury >= finalswap:
- if len(replacelist) > 0:
- finalswap = max(replacelist)
- replacelist = []
- Common.MoveTo(get_pos_x(),0)
- else: #its sorted now next list
- break
- #first time end of row reached
- if get_pos_y() == worldsize-1:
- if len(replacelist) > 0:
- quick_print(max(replacelist))
- finalswap = max(replacelist)
- replacelist = []
- else:
- finalswap = curx
- move(East)
- Common.MoveTo(get_pos_x(),0)
- replacelist = []
- #Harvest em all
- def charvest():
- worldsize = get_world_size()
- Common.MoveTo(worldsize-1,worldsize-1)
- harvest()
- #***************MULTI CODE!!!!*****
- def cplantMulti():
- #plant a row of Cactus
- for x in range(worldsize):
- if get_ground_type() != Grounds.Soil:
- till()
- if get_entity_type() != Entities.Cactus:
- harvest()
- plant(Entities.Cactus)
- move(East)
- #sort row multi
- def MultiRowSort():
- worldsize = get_world_size()
- #Sort rows
- replacelist = []
- sorted = worldsize-1
- finalswap = worldsize-1
- while sorted != 0:
- move(East)
- curx = get_pos_x()
- if measure() < measure(West) and curx > 0:
- swap(West)
- sorted = worldsize-1
- replacelist.append(curx)
- else:
- sorted -= 1
- #done with swaps, get the new last position and reset list
- if curx >= finalswap:
- if len(replacelist) > 0:
- finalswap = max(replacelist)
- replacelist = []
- Common.MoveTo(0,get_pos_y())
- else: #its sorted now next list
- break
- #first time end of row reached
- if get_pos_x() == worldsize-1:
- if len(replacelist) > 0:
- #quick_print(max(replacelist))
- finalswap = max(replacelist)
- replacelist = []
- else:
- finalswap = curx
- def MultiColSort():
- worldsize = get_world_size()
- #Sort rows
- replacelist = []
- sorted = worldsize-1
- finalswap = worldsize-1
- while sorted != 0:
- move(North)
- cury = get_pos_y()
- if measure() < measure(South) and cury > 0:
- swap(South)
- sorted = worldsize-1
- replacelist.append(cury)
- else:
- sorted -= 1
- #done with swaps, get the new last position and reset list
- if cury >= finalswap:
- if len(replacelist) > 0:
- finalswap = max(replacelist)
- replacelist = []
- Common.MoveTo(get_pos_x(),0)
- else: #its sorted now next list
- break
- #first time end of row reached
- if get_pos_y() == worldsize-1:
- if len(replacelist) > 0:
- #quick_print(max(replacelist))
- finalswap = max(replacelist)
- replacelist = []
- else:
- finalswap = cury
- def doCactus(size):
- #set custom size as needed
- if get_world_size() != size:
- set_world_size(size)
- Common.MoveTo(0,0)
- if num_unlocked(Unlocks.Megafarm) > 0:
- #multi plant
- for y in range(size):
- if num_drones() < max_drones():
- spawn_drone(cplantMulti)
- else:
- cplantMulti()
- move(North)
- #Multi Sort
- #row
- drones = []
- Common.MoveTo(0,0)
- while get_pos_y() < size-1:
- if num_drones() < max_drones():
- newdrone = spawn_drone(MultiRowSort)
- drones.append(newdrone)
- move(North)
- #else:
- # MultiRowSort()
- for drone in drones:
- if has_finished(drone):
- drones.remove(drone)
- #sometimes the last row is missed
- MultiRowSort()
- for drone in drones:
- wait_for(drone)
- #Columns
- Common.MoveTo(0,0)
- drones = []
- while get_pos_x() < size-1:
- if num_drones() < max_drones():
- newdrone = spawn_drone(MultiColSort)
- drones.append(newdrone)
- move(East)
- #else:
- #MultiColSort()
- for drone in drones:
- if has_finished(drone):
- drones.remove(drone)
- MultiColSort()
- for drone in drones:
- wait_for(drone)
- #sort complete?!
- charvest()
- #Single drone code
- else:
- cplant()
- csort()
- charvest()
Advertisement
Add Comment
Please, Sign In to add comment