<code>Start Farm Bot!
[15:18:29] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:29] MESSAGE: Harvest
[15:18:30] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:30] MESSAGE: 'Player' object has no attribute 'scissor'
</code>
<code>Start Farm Bot!
[15:18:29] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:29] MESSAGE: Harvest
[15:18:30] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:30] MESSAGE: 'Player' object has no attribute 'scissor'
</code>
Start Farm Bot!
[15:18:29] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:29] MESSAGE: Harvest
[15:18:30] MESSAGE: Error in updatePos: Could not locate the image (highest confidence = 0.429)
[15:18:30] MESSAGE: 'Player' object has no attribute 'scissor'
I installed : pip install pyautogui
<code>import pyautogui
from dotenv import load_dotenv
from cryptography.fernet import Fernet
import requests
load_dotenv("config.txt")
class Player:
def __init__(self):
self.KEY_SHORTCUT_SCISSOR = str(os.getenv('KEY_SHORTCUT_SCISSOR', 2))
self.updatePos()
def updatePos(self):
try:
self.scissor = self.safeGetPos("scissor")
except Exception as e:
self.log(f"Error in updatePos: {e}")
def safeGetPos(self, file, conf=0.6):
pos = self.getPos(file, conf)
if not pos:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return pos
# def safeGetAllPos(self, file, conf=0.7):
def safeGetAllPos(self, file, conf=0.7):
positions = self.getAllPos(file, conf)
if not positions:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return positions
def getPos(self, file, conf=0.6):
pos = pyautogui.locateCenterOnScreen(f'./sample/{file}.png', confidence=conf)
if pos is None:
self.log(f"Position not found: {file} (confidence = {conf})")
return pos
def getAllPos(self, file, conf=0.7):
positions = list(pyautogui.locateAllOnScreen(f'./sample/{file}.png', confidence=conf))
if not positions:
self.log(f"Positions not found: {file} (confidence = {conf})")
return positions
</code>
<code>import pyautogui
from dotenv import load_dotenv
from cryptography.fernet import Fernet
import requests
load_dotenv("config.txt")
class Player:
def __init__(self):
self.KEY_SHORTCUT_SCISSOR = str(os.getenv('KEY_SHORTCUT_SCISSOR', 2))
self.updatePos()
def updatePos(self):
try:
self.scissor = self.safeGetPos("scissor")
except Exception as e:
self.log(f"Error in updatePos: {e}")
def safeGetPos(self, file, conf=0.6):
pos = self.getPos(file, conf)
if not pos:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return pos
# def safeGetAllPos(self, file, conf=0.7):
def safeGetAllPos(self, file, conf=0.7):
positions = self.getAllPos(file, conf)
if not positions:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return positions
def getPos(self, file, conf=0.6):
pos = pyautogui.locateCenterOnScreen(f'./sample/{file}.png', confidence=conf)
if pos is None:
self.log(f"Position not found: {file} (confidence = {conf})")
return pos
def getAllPos(self, file, conf=0.7):
positions = list(pyautogui.locateAllOnScreen(f'./sample/{file}.png', confidence=conf))
if not positions:
self.log(f"Positions not found: {file} (confidence = {conf})")
return positions
</code>
import pyautogui
from dotenv import load_dotenv
from cryptography.fernet import Fernet
import requests
load_dotenv("config.txt")
class Player:
def __init__(self):
self.KEY_SHORTCUT_SCISSOR = str(os.getenv('KEY_SHORTCUT_SCISSOR', 2))
self.updatePos()
def updatePos(self):
try:
self.scissor = self.safeGetPos("scissor")
except Exception as e:
self.log(f"Error in updatePos: {e}")
def safeGetPos(self, file, conf=0.6):
pos = self.getPos(file, conf)
if not pos:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return pos
# def safeGetAllPos(self, file, conf=0.7):
def safeGetAllPos(self, file, conf=0.7):
positions = self.getAllPos(file, conf)
if not positions:
raise Exception(f"Could not locate the image {file} (confidence = {conf})")
return positions
def getPos(self, file, conf=0.6):
pos = pyautogui.locateCenterOnScreen(f'./sample/{file}.png', confidence=conf)
if pos is None:
self.log(f"Position not found: {file} (confidence = {conf})")
return pos
def getAllPos(self, file, conf=0.7):
positions = list(pyautogui.locateAllOnScreen(f'./sample/{file}.png', confidence=conf))
if not positions:
self.log(f"Positions not found: {file} (confidence = {conf})")
return positions
New contributor
Lazy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.