S
S
Snoppybot2021-12-07 19:46:57
Python
Snoppybot, 2021-12-07 19:46:57

How to write in If that would be greater than 0 but less than 35?

Script for the game, machine. teleport home at 1 - 35% hp:

def aboba():
    pyautogui.press('enter'), pyautogui.typewrite('/homefast'), pyautogui.press('enter')
    print("хом")
    time.sleep(1)

time.sleep(1)
while True:
    if __name__ == "__main__":
        im = ImageGrab.grab(bbox=(190, 1011, 215, 1023))  # X1,Y1,X2,Y2
        im.save('screen.png')
        img = cv2.imread('screen.png')
        img = cv2.resize(img, None, fx=9, fy=9)
        HP = pytesseract.image_to_string(img, config='outputbase digits')
        print(HP)
        if HP > str(0) and HP < str(range(1, 36)):
            aboba()

But when the number is 1009 (there is 100 HP and the percentage he recognizes as 9) he writes /homefast in the chat, although he should not do this.
How can this be fixed? Here is the console output:
1009

hom
1009

hom

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
HemulGM, 2021-12-07
@Snoppybot

if (a > 0) and (a < 35):
a is a number

N
nvlveu, 2021-12-07
@nvlveu

There is only one way out: learn the basics of Python

V
Vasily Bannikov, 2021-12-07
@vabka

hpInt = int(HP[:-1]) # [:-1] чтобы убрать последний символ, который 9, который кривой процент.
if 0 < hpInt and hpInt < 35:
    aboba()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question