def check_cargo(self, scr): template = Image.open('img_templates/cargo.jpg') coords = detector(scr, template) pyautogui.moveTo(coords[0], coords[1]) time.sleep(1) sc = ImageGrab.grab() text = read_screen_neg(sc, (coords[0] - 90, coords[1] - 130, coords[0] + 75, coords[1] - 15), 100) text = text.replace('%', '') idx = text.find('Ore Hold') try: self.cargo = float(text[idx + 8:idx + 8 + 6]) except: self.cargo = 0
def get_objects(self, overview, n_obj=5): self.select_overview(overview=overview) time.sleep(0.2) scr = ImageGrab.grab() obj_area = scr.crop((1673, 185, 1834, 617)) # TODO: Get this area automatic interval = 19 objs = [] for i in range(n_obj): start = i * interval temp_list = read_screen_neg(obj_area, (0, start, 430, start + interval), 100).split(' ')[:3] try: dist, um, obj = temp_list except: dist, um, obj = (500, 'km', (300,300)) print('Error getting object') try: dist = int(dist) except: for char in numbers_replaces: dist = dist.replace(char, numbers_replaces[char]) dist = ''.join([x for x in dist if x in '0123456789']) try: dist = int(dist) except: dist = 0 if um == 'm': dist = dist elif um == 'km': dist = dist * 1000 else: dist = dist * 1000000 click = (1750, start + 10 + 185) objs.append([dist, obj, click]) self.objects = objs
def test_docked(self, scr): return read_screen_neg(scr, (1743, 174, 1837, 196), 180) == 'UNDOCK'
def read_location(self, scr): self.location = read_screen_neg(scr, (77, 135, 344, 154), 200)
def read_targeted(self, scr): texto = read_screen_neg(scr, (1541, 114, 1643, 170), 120) print(texto) return texto