I'm trying to make an script that reacts when for example, my hp and mana bar go down.
I wrote this code:
Code: Select all
CoordMode, Pixel, window
vida()
{
PixelSearch, , , 687, 405, 713, 417, 0x09FF10, 5, Fast
return
}
mana()
{
PixelSearch, , , 618, 455, 705, 461, 0xFF00FF, 5, Fast
return
}
#persistent
SetTimer, general, 100
general:
vida()
mana()
return
v := vida()
m := mana()
z::
SetTimer, general, OFF
Msgbox % "vida:" . %v% . "mana:" . %m%
return
Then i wrote this code:
Code: Select all
CoordMode, Pixel, window
#persistent
SetTimer, general, 100
SetTimer, life, 100
return
life:
PixelSearch, , , 618, 455, 705, 461, 0xFF00FF, 5, Fast ; This will check if my hp bar is full
Return
mana:
PixelSearch, , , 687, 405, 713, 417, 0x09FF10, 5, Fast ; This will check if my mana bar is full
return
General:
If ( ErrorLevel = 1 ) ; Because only life's timer is working, error level will come from life's pixel search.
{
SetTimer, life, off ; If it's 1 then it's full and that means i have to turn off life's pixel search and i have to turn on mana's pixel search
SetTimer, mana, 100
If ( ErrorLevel = 1 ) ; Because only mana's timer is working, error level will come from mana's pixel search
{
SetTimer, mana, off ; If it's 1 then it's full and that means i have to turn off mana's pixel search and i have to turn on life's pixel search
SetTimer, life, 100
}
Else
{
MsgBox Low Mana ; If second If it's 0 then mana is low and it will open a msgbox showing "Low Mana"
SetTimer, mana, off ; Because msgbox has been shown mana's pixel search is turned off
}
}
Else
{
MsgBox Low HP ;If first If it's 0 then hp is low and it will open a msgbox showing "Low HP"
SetTimer, life, off ; Because msgbox has been shown mana's pixel search is turned off
}
I want it to prioritize HP check and then if HP is full, check mana but always checking for hp, because if hp was full at start it focuses on mana and then hp is low, i want it to focus on hp again.
The problem is that i think it's not good and it doesn't work as intended.
Hope you can understand what i'm trying to explain, english is not my main language.
All help is appreciated and if you need more explanation or something, tell me.
PD: i don't want you to do all the job, i want to learn what did you change on my code or what do you think about and why.
Thanks in advance