get("#348") -- rgb and bright get("#137") -- split get("#390") -- msinsert y, w, h = img.height-19, 20, 17 x = img.width-w if y < 0 or y+h > img.height then return "No Battery Symbol" end icon = [[ YYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYYYYY YLCCCCCCCCCCCCCCLYXX YEEEEEEEEEEEEEEEEYXX XFFS???????????FFXXX XGGU???????????GGXXX XGGT???????????GGDHX XHHT???????????HHHGX XIIT???????????IIIIX WIIT???????????IIINW WJJT???????????JJXXW WKKO??????????OKKWWW WLKHFFFFFFFFFFHKLWVV VSMLLLLLLLLLLLLMSVVV VWXXXXXXXXXXXXXXWVVV VVVVVVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVVVVVV ]] icon = split(icon, "\n") -- count non-question marks count = 0 for yy=1, h do line = icon[yy] for xx=1, w do c = line:sub(xx, xx) if c ~= '?' then count=count+1 end end end limit = count*25/100 while x >= 0 do total, innerPixels = 0, {} for yy=y, y+h-1 do line = icon[yy-y+1] for xx=x, x+w-1 do pix = img.getInt(xx, yy) c = line:sub(xx-x+1, xx-x+1) if c == '?' then msinsert(innerPixels, pix) else b = math.floor(bright(rgb(pix))*25+0.5) lb = string.byte(c)-string.byte("A") diff = math.abs(b-lb) total = total+diff if total> limit then goto out end end end end sim = math.floor(100*(1-total/(count*25))+0.5) print("Similarity at x="..x..": "..sim.."%") if sim >= 99 then return "Battery Symbol: "..x..", "..y..", "..x+w..", "..y+h end ::out:: x = x-1 end x = nil return "No Battery Symbol" -- innerPixels and x, y, w, h are returned for including snippets