|
Post by paladiex on Aug 11, 2017 19:09:46 GMT
Hi! I have 3 pictures I need to scan a specific pixel within that red box and return a rgb value. Looking at the "getcolor()" explanation in AnkuLua's quick api reference sheet I do not believe I can use this in that way. Edit 1: I a 1x1px screenshot from each area and checked in paint, the rgb values are all different. Greyscale only I suppose.
|
|
|
Post by Exilereven on Aug 11, 2017 20:02:16 GMT
To get real basic:
Local loc = Location(100,100)
Local r,g,b = getColor(loc)
Toast(r..g..b)
You can do whatever you need to with the r,g,b variables.
Ex:
If (r < 0 b<=60 g > 20) then -- do somwthing
|
|
|
Post by paladiex on Aug 11, 2017 20:20:07 GMT
To get real basic: Local loc = Location(100,100) Local r,g,b = getColor(loc) Toast(r..g..b) You can do whatever you need to with the r,g,b variables. Ex: If (r < 0 b<=60 g > 20) then -- do somwthing Thanks bro, you the real mvp That's all I needed!
|
|
|
Post by Exilereven on Aug 11, 2017 20:22:55 GMT
Forrusco taught me most of what I know, so atleast some credit goes there, but thank you anyway, your welcome.
|
|
|
Post by paladiex on Aug 11, 2017 21:38:50 GMT
Forrusco taught me most of what I know, so atleast some credit goes there, but thank you anyway, your welcome. Forrusco and Ankulua help me out a lot too, they're awesome You helped me with this one this time so you get the credit function findRuneRarity() (Location(800, 480)):highlight() local loc = Location(800, 480) local r,g,b = getColor(loc) if (r == 134 and b == 23 and g == 16) then runeRarity = "Legendary" elseif (r == 83 and b == 60 and g == 15) then runeRarity = "Hero" elseif (r == 19 and b == 70 and g == 45) then runeRarity = "Rare" elseif (r == 29 and b == 27 and g == 57) then runeRarity = "Magic" elseif (r ==57 and b == 38 and g == 45) then runeRarity = "Normal" else runeRarity = "Unknown" end (Location(800, 480)):highlight() statRegion9:highlight("Rune Rarity: " .. runeRarity) end The above code works perfectly! I couldn't use image recognition here because I would have to scan a very small location and image. For some reason Ankulua wasn't recognizing a difference, I guess due to greyscale conversion. I tried to search the forum but most people wanted to scan an image for specific pixels.
|
|
|
Post by Exilereven on Aug 11, 2017 21:47:35 GMT
I had the same problem detecting hp with a gradient from green to red via yellow in the middle. Which was possible but ankulua seems tk have a hard time with small crops. a very small image, it would only find it 1/4 times, adjusted all my specifications best I could still no result. This approach seems perfect for something like that so I could set red and detect single pixel location for color change, then will heal based on color. Works pretty fast. But most other image recognition works perfectly for botting, just sometimes a single pixel color argument just works out way better and wayyyyy less code.
|
|
|
Post by paladiex on Aug 12, 2017 14:53:28 GMT
I had the same problem detecting hp with a gradient from green to red via yellow in the middle. Which was possible but ankulua seems tk have a hard time with small crops. a very small image, it would only find it 1/4 times, adjusted all my specifications best I could still no result. This approach seems perfect for something like that so I could set red and detect single pixel location for color change, then will heal based on color. Works pretty fast. But most other image recognition works perfectly for botting, just sometimes a single pixel color argument just works out way better and wayyyyy less code. So, I'm running into a new issue. local loc = Location(798, 338)
local r, g, b = getColor(loc)
toast ("r:" .. r .. " g:" .. g .. " b:" .. b)
if (r == (253 or 244) and g == (208 or 58 or 59) and b == (12 or 222 or 223)) then
runeRank = 6 The above line of code is displaying "r: 244 g: 58 b: 222" but for some reason it is not setting runeRank = 6, but when it displays "r: 253 g: 208 b: 12" it correctly assigns runeRank = 6. Any ideas on why?
|
|
|
Post by Exilereven on Aug 12, 2017 15:09:51 GMT
Try using < > instead of exact numbers.
Example: if (r>=0 and g>=0 and b>=200) would pick up the blue color only when it hits the threshold of 200 or bluer. But you need to find the ranges manually so you know what's changing. But, if you only use == your making it exact which the pixel may skip over that color or not. This allows something to happen if it hits that mark or more, or you can make it a range.
|
|
|
Post by paladiex on Aug 12, 2017 15:20:39 GMT
Try using < > instead of exact numbers. Example: if (r>=0 and g>=0 and b>=200) would pick up the blue color only when it hits the threshold of 200 or bluer. But you need to find the ranges manually so you know what's changing. But, if you only use == your making it exact which the pixel may skip over that color or not. This allows something to happen if it hits that mark or more, or you can make it a range. I need an exact match, the colors of the background there changes, I need it to hit on purple and yellow. Does Ankulua not understand "or" ? I'm confused why I am not getting a positive match in my code there.
|
|
|
Post by Exilereven on Aug 12, 2017 15:28:20 GMT
Example if I wanted to detect when green turns to yellow and then into red. So I can detect health bar color change, from same exact loc. And it works perfect.
if (r==0 and g > 250 and b>=0) then hp = "100%" end if (r>=64 and g > 250 and b>=0) then hp = "75%" end if (r>= 190 and g > 0 and b>=0) then hp = "50%" end if (r > 250 and g<=80 and b>=0) then hp = "25%" end
|
|
|
Post by paladiex on Aug 12, 2017 15:45:44 GMT
Example if I wanted to detect when green turns to yellow and then into red. So I can detect health bar color change, from same exact loc. And it works perfect. if (r==0 and g > 250 and b>=0) then hp = "100%" end if (r>=64 and g > 250 and b>=0) then hp = "75%" end if (r>= 190 and g > 0 and b>=0) then hp = "50%" end if (r > 250 and g<=80 and b>=0) then hp = "25%" end So, I switched to the code below and it's working local loc = Location(798, 338) local r, g, b = getColor(loc) if (r == 253 and g == 208 and b == 12) then runeRank = 6 elseif (r == 244 and g == 58 and b == 222) then runeRank = 6 elseif (r == 244 and g == 59 and b == 223) then runeRank = 6 else But this seems inefficient code length wise
|
|
|
Post by Exilereven on Aug 12, 2017 17:32:59 GMT
Not a pro, just know it works
|
|