I developed this script in SIKULI, but I would like to add more functions and I'm thinking about using Python and learning the language. SIKULI has OCR but still contains some bugs, not performing so well. Likewise I would like to use OCR/tesseract/pytesseract in python.
The idea of this script is to make you heal in a game, according to the current % of health, reading the number of the current health bar vs the total value it has. After reading this number, a calculation is performed with the result in %.
Could you help me fix this script by inserting the necessary libraries and tweaking the code to make it work in Python?
#==Config HP==
Healing_1 = 95
Hk_healing_1 = '5'
Healing_2 = 65
Hk_healing_2 = '1'
Healing_3 = 30
Hk_healing_3 = '3'
#==Code==
while True:
GAME = App("GAME")
GAME.focus()
Settings.OcrTextRead = True
#==hp==
hp = Region(88,28,191,23)
hp = hp.text()
hp2 = hp.replace(",","")
X = hp2.split("/")
try:
check_hp = float(X[0]) / float(X[1]) * 100
except:
type(Hk_healing_3)
#==hp check==
if check_hp < 100:
if check_hp <= Healing_3:
type(Hk_healing_3)
elif check_hp <= Healing_2:
type(Hk_healing_2)
elif check_hp <= Healing_1:
type(Hk_healing_1)
else:
pass
Just for information, this function should identify the text in a region of the screen. The text of the screen, will be displayed as xxxx/xxxx (current value / total value) - it's could be other format as x/x, xx/xx, xxx/xxx, xxxx/xxxx, xxxxx/xxxxx, x/xxxx, x/xxxxxxx ...
The text will be split to perform the calculation (% of current value).