|
Post by paladiex on Aug 8, 2017 22:09:54 GMT
I know ankulua works in this order take picture compare picture perform action
Is there any way to get it to take picture compare multiple pictures perform action based on picture match
Currently I have
function findMainStat()
mainStatRegion:highlight()
if mainStatRegion:exists(hpMain) then
mainStat = "HP"
elseif mainStatRegion:exists(defMain) then
mainStat = "DEF"
elseif mainStatRegion:exists(atkMain) then
mainStat = "ATK"
elseif mainStatRegion:exists(spdMain) then
mainStat = "SPD"
elseif mainStatRegion:exists(criRateMain) then
mainStat = "CRI Rate"
elseif mainStatRegion:exists(criDmgMain) then
mainStat = "CRI DMG"
elseif mainStatRegion:exists(resMain) then
mainStat = "RES"
elseif mainStatRegion:exists(accMain) then
mainStat = "ACC"
The bot performs these actions for 5 sections, this results in hp being found in roughly 7 seconds, while acc takes around 32 seconds. I suppose I can begin to crop the image smaller and smaller but that will run into detection issues eventually. I was hoping I could speed up performance by having the bot compare 1 image to several .png files. Is this possible?
|
|
|
Post by AnkuLua on Aug 8, 2017 23:49:36 GMT
|
|
|
Post by paladiex on Aug 9, 2017 5:44:03 GMT
Is this like a setting that I can toggle? usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" elseif mainStatRegion:exists(defMain) then mainStat = "DEF" elseif mainStatRegion:exists(atkMain) then mainStat = "ATK" or would I need to place it at the start of each iteration. usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" usePreviousSnap(true) elseif mainStatRegion:exists(defMain) then mainStat = "DEF" usePreviousSnap(true) elseif mainStatRegion:exists(atkMain) then mainStat = "ATK"
|
|
|
Post by Mercobots on Aug 10, 2017 0:26:03 GMT
see if that helps -- load ankulua commonLib commonLib = loadstring(httpGet("https://raw.githubusercontent.com/AnkuLua/commonLib/master/commonLib.lua"))()
-- data obj, just for the example data = { images = { "hpMain.png", "defMain.png", "atkMain.png" }, str = { "HP", "DEF", "ATK" } }
-- check all images at mainStatRegion index, match = existsMultiMax(data.images, mainStatRegion)
-- if image found then if match then match:highlight(2) print("Image Found -> ", data.images[index]) print("Related String -> ", data.str[index]) end
|
|
|
Post by paladiex on Aug 10, 2017 1:20:41 GMT
see if that helps -- load ankulua commonLib commonLib = loadstring(httpGet("https://raw.githubusercontent.com/AnkuLua/commonLib/master/commonLib.lua"))()
-- data obj, just for the example data = { images = { "hpMain.png", "defMain.png", "atkMain.png" }, str = { "HP", "DEF", "ATK" } }
-- check all images at mainStatRegion index, match = existsMultiMax(data.images, mainStatRegion)
-- if image found then if match then match:highlight(2) print("Image Found -> ", data.images[index]) print("Related String -> ", data.str[index]) end Not really sure this is what I want it to do. I want it to take 1 screenshot, then compare it to 8 images, if 1 of those images is found then the bot needs to proceed based on the image it has found. Correct me if I am wrong, but what you sent me appears to take 1 screen shot, then compare it to the images, then if any image is found it proceeds. I've never used "index" or "match", if I can achieve what I want faster using your method I would be much appreciative.
|
|
|
Post by AnkuLua on Aug 10, 2017 1:30:02 GMT
Is this like a setting that I can toggle? usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" elseif mainStatRegion:exists(defMain) then mainStat = "DEF" elseif mainStatRegion:exists(atkMain) then mainStat = "ATK" or would I need to place it at the start of each iteration. usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" usePreviousSnap(true) elseif mainStatRegion:exists(defMain) then mainStat = "DEF" usePreviousSnap(true) elseif mainStatRegion:exists(atkMain) then mainStat = "ATK" It's easier for you to use regionWaitMulti() in commonLib.lua ankulua.boards.net/thread/169/common-library-autoresizePlease refer to the script of regionWaitMulti().
|
|
|
Post by paladiex on Aug 10, 2017 1:58:08 GMT
Is this like a setting that I can toggle? usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" elseif mainStatRegion:exists(defMain) then mainStat = "DEF" elseif mainStatRegion:exists(atkMain) then mainStat = "ATK" or would I need to place it at the start of each iteration. usePreviousSnap(true) if mainStatRegion:exists(hpMain) then mainStat = "HP" usePreviousSnap(true) elseif mainStatRegion:exists(defMain) then mainStat = "DEF" usePreviousSnap(true) elseif mainStatRegion:exists(atkMain) then mainStat = "ATK" It's easier for you to use regionWaitMulti() in commonLib.lua ankulua.boards.net/thread/169/common-library-autoresizePlease refer to the script of regionWaitMulti(). I'm confused. I see "regionWaitMulti(target, seconds, debug, skipLocation)" but I am not understanding it. Is the target a data set of multiple png files? Or is the target the region? debug just highlights the area, right? Not sure what skiplocation is. I can see "return i, t.id, match" which is what it will return when it sees a match, but I do not understand what that would look like. Edit 1: Sorry, I learn from example and I cannot find any resources online other than your API quick reference page; but that doesn't really go over this.
|
|
|
Post by AnkuLua on Aug 10, 2017 2:27:15 GMT
In your example, target = {{target = hpMain, region = mainStatRegion, id = "HP"}, {target = defMain, region = mainStatRegion, id = "DEF"}, {target = atkMain, region = mainStatRegion, id = "ATK"}, }
regionWaitMulti(target, 10, true, nil) -- adjust seconds by your request. Here, it will search up to 10 seconds before aborting searching.
|
|
|
Post by paladiex on Aug 10, 2017 2:52:02 GMT
In your example, target = {{target = hpMain, region = mainStatRegion, id = "HP"}, {target = defMain, region = mainStatRegion, id = "DEF"}, {target = atkMain, region = mainStatRegion, id = "ATK"}, } regionWaitMulti(target, 10, true, nil) -- adjust seconds by your request. Here, it will search up to 10 seconds before aborting searching. Should this work then? data = { sixStarImages = { {sixStarLvl0 = (Pattern("6starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0"}, {sixStarLvl1 = (Pattern("6starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1"}, {sixStarLvl2 = (Pattern("6starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2"}, {sixStarLvl3 = (Pattern("6starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3"}, {sixStarLvl4 = (Pattern("6starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4"}, {sixStarLvl5 = (Pattern("6starLvl5.png"):similar(.70)), region = runeLvlRegion, id = "Level 5"}, {sixStarLvl6 = (Pattern("6starLvl6.png"):similar(.70)), region = runeLvlRegion, id = "Level 6"}, {sixStarLvl7 = (Pattern("6starLvl7.png"):similar(.70)), region = runeLvlRegion, id = "Level 7"}, {sixStarLvl8 = (Pattern("6starLvl8.png"):similar(.70)), region = runeLvlRegion, id = "Level 8"}, {sixStarLvl9 = (Pattern("6starLvl9.png"):similar(.70)), region = runeLvlRegion, id = "Level 9"}, {sixStarLvl10 = (Pattern("6starLvl10.png"):similar(.70)), region = runeLvlRegion, id = "Level 10"}, {sixStarLvl11 = (Pattern("6starLvl11.png"):similar(.70)), region = runeLvlRegion, id = "Level 11"}, {sixStarLvl12 = (Pattern("6starLvl12.png"):similar(.70)), region = runeLvlRegion, id = "Level 12"}, {sixStarLvl13 = (Pattern("6starLvl13.png"):similar(.70)), region = runeLvlRegion, id = "Level 13"}, {sixStarLvl14 = (Pattern("6starLvl14.png"):similar(.70)), region = runeLvlRegion, id = "Level 14"}, {sixStarLvl15 = (Pattern("6starLvl15.png"):similar(.70)), region = runeLvlRegion, id = "Level 15"} }, fiveStarImages = { {fiveStarLvl0 = (Pattern("5starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0"}, {fiveStarLvl1 = (Pattern("5starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1"}, {fiveStarLvl2 = (Pattern("5starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2"}, {fiveStarLvl3 = (Pattern("5starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3"}, {fiveStarLvl4 = (Pattern("5starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4"}, {fiveStarLvl5 = (Pattern("5starLvl5.png"):similar(.70)), region = runeLvlRegion, id = "Level 5"}, {fiveStarLvl6 = (Pattern("5starLvl6.png"):similar(.70)), region = runeLvlRegion, id = "Level 6"}, {fiveStarLvl7 = (Pattern("5starLvl7.png"):similar(.70)), region = runeLvlRegion, id = "Level 7"}, {fiveStarLvl8 = (Pattern("5starLvl8.png"):similar(.70)), region = runeLvlRegion, id = "Level 8"}, {fiveStarLvl9 = (Pattern("5starLvl9.png"):similar(.70)), region = runeLvlRegion, id = "Level 9"}, {fiveStarLvl10 = (Pattern("5starLvl10.png"):similar(.70)), region = runeLvlRegion, id = "Level 10"}, {fiveStarLvl11 = (Pattern("5starLvl11.png"):similar(.70)), region = runeLvlRegion, id = "Level 11"}, {fiveStarLvl12 = (Pattern("5starLvl12.png"):similar(.70)), region = runeLvlRegion, id = "Level 12"}, {fiveStarLvl13 = (Pattern("5starLvl13.png"):similar(.70)), region = runeLvlRegion, id = "Level 13"}, {fiveStarLvl14 = (Pattern("5starLvl14.png"):similar(.70)), region = runeLvlRegion, id = "Level 14"}, {fiveStarLvl15 = (Pattern("5starLvl15.png"):similar(.70)), region = runeLvlRegion, id = "Level 15"} } } function findRuneLvl() runeLvlRegion:highlight() if runeRank == 6 then regionWaitMulti(data.sixStarImages, 30, true, nil) runeLvl = id end if runeRank == 5 then regionWaitMulti(data.fiveStarImages, 30, true, nil) runeLvl = id end runeLvlRegion:highlight() statRegion8:highlight("Rune" .. runeLvl) end This resulted in "Runtime error: java.lang.NullPointerException stack traceback: [C]:in function 'exists' [string "-- ======= dimension related ======..."]68: in function 'regionWaitMulti' .../PalPowerUp.lua:129: in function 'findRuneLvl' .../PalPowerUp.lua:438: in main chunk" Edit 1: Changed some things back and fourth, I can't get this to work. I keep getting the dimension related error, dunno what's going on there. >.>
|
|
|
Post by Mercobots on Aug 10, 2017 9:58:35 GMT
your sixStarLvl must be target instead
data = { sixStarImages = { { target = (Pattern("6starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0" }, { target = (Pattern("6starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1" }, { target = (Pattern("6starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2" }, { target = (Pattern("6starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3" }, { target = (Pattern("6starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4" }, -- ... }, fiveStarImages = { { target = (Pattern("5starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0" }, { target = (Pattern("5starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1" }, { target = (Pattern("5starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2" }, { target = (Pattern("5starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3" }, { target = (Pattern("5starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4" }, -- ... } }
function findRuneLvl() runeLvlRegion:highlight() if runeRank == 6 then local i, id, match = regionWaitMulti(data.sixStarImages, 30, true, nil) print("Rune Rank - ", 6) print("i - ", i) print("id - ", id) print("match - ", match) end if runeRank == 5 then local i, id, match = regionWaitMulti(data.fiveStarImages, 30, true, nil) runeLvl = id print("Rune Rank - ", 5) print("i - ", i) print("id - ", id) print("match - ", match) end
runeLvlRegion:highlight() statRegion8:highlight("Rune" .. runeLvl) end
Not tested
|
|
|
Post by paladiex on Aug 10, 2017 15:28:00 GMT
your sixStarLvl must be target instead data = { sixStarImages = { { target = (Pattern("6starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0" }, { target = (Pattern("6starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1" }, { target = (Pattern("6starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2" }, { target = (Pattern("6starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3" }, { target = (Pattern("6starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4" }, -- ... }, fiveStarImages = { { target = (Pattern("5starLvl0.png"):similar(.70)), region = runeLvlRegion, id = "Level 0" }, { target = (Pattern("5starLvl1.png"):similar(.70)), region = runeLvlRegion, id = "Level 1" }, { target = (Pattern("5starLvl2.png"):similar(.70)), region = runeLvlRegion, id = "Level 2" }, { target = (Pattern("5starLvl3.png"):similar(.70)), region = runeLvlRegion, id = "Level 3" }, { target = (Pattern("5starLvl4.png"):similar(.70)), region = runeLvlRegion, id = "Level 4" }, -- ... } } function findRuneLvl() runeLvlRegion:highlight() if runeRank == 6 then local i, id, match = regionWaitMulti(data.sixStarImages, 30, true, nil) print("Rune Rank - ", 6) print("i - ", i) print("id - ", id) print("match - ", match) end if runeRank == 5 then local i, id, match = regionWaitMulti(data.fiveStarImages, 30, true, nil) runeLvl = id print("Rune Rank - ", 5) print("i - ", i) print("id - ", id) print("match - ", match) end
runeLvlRegion:highlight() statRegion8:highlight("Rune" .. runeLvl) end
Not testedI keep getting that dimension related error I posted above :/
|
|
|
Post by Mercobots on Aug 10, 2017 15:43:42 GMT
try to remove the () like this
target = (Pattern("5starLvl0.png"):similar(.70))
target = Pattern("5starLvl0.png"):similar(.70)
|
|
|
Post by AutoBOT on Aug 11, 2017 1:15:49 GMT
try to remove the () like this target = (Pattern("5starLvl0.png"):similar(.70) )target = Pattern("5starLvl0.png"):similar(.70) mine was like that and works perfectly fine victory = (Pattern("victory.png"):similar(0.70)) scenarioEyes = { {target = victory, region = regTop}, {target = victory2, region = regTop}} *sorry the format, from mobile*
|
|