# Logic to make a percent from a value

## Recommended Posts

Hi,

i was thinking on how to get a percent from this piece of code but i couldnt get it to the paper:

```\$MobHP = PixelSearch(736,48,910,49,0x3F3830,3) ; 173 pixels of hp
If Not @error Then ;If pixel has been found to \$coord
\$MobHPvalue = 909 - \$MobHP[0]
EndIf```

So if you see the piece of code i will get X every time i find the image i want the image i am looking for is an Health Bar that goes down from the right to the left so the value i get from 909 - X is from 0 to 173 since 909 - 736 = 173.

So my question is how could i make it a 99% to 1% as it substracts it self to 173

1 = 99% and 173 = 0%

i could make it by checking if X is bigger then X_new and small then X_next and create % by hand but it would look so ugly that i would like to find a new better way of doing it

thanks for any help in advance

##### Share on other sites

'(173 - x) / 173'?

##### Share on other sites

Thank you very much for the fast reply don't belive i didnt came to that ...

(173 - \$MobHPvalueX) / 173 * 100

just did the trick thanks a lot ...

## Create an account

Register a new account