Post by willingtolearnnewbie on Feb 26, 2020 10:15:14 GMT
Hi goodday, i made my first automated script for certain game, i got it working thanks to mercobots for their debugger for image finding and ankulua admin for making the app, I need help regarding my script, it works, it detects those images ive set and my regions, but after a few image recognition of the script, it fails to recognize the images on my regions like it was just checking and doing nothing, my built code looks like this
----- created by AnkuLua snap and play script ------
dofile(scriptPath() .. "DebugMyScript.luac")
Image:menu()
immersive = true
setImmersiveMode(immersive)
genVersion = "8.3.0-PRO2"
setAutoGameArea = true
pcall (autoGameArea, setAutoGameArea)
scriptDimension = 2340
Settings:setScriptDimension(true, scriptDimension)
Settings:setCompareDimension(true, scriptDimension)
ROOT = scriptPath()
DIR_IMAGES = ROOT .. "expImage"
setImagePath(DIR_IMAGES)
timeout = 2
local timer = Timer()
Settings:set("MinSimilarity", 0.7)
setDragDropStepCount(6)
setDragDropStepInterval(100)
setScanInterval(0.3)
local fullinvent = {}
local heavyinvent = {}
local heavyinvent1 = {}
PopUps = {
"Close.png",
"Exit.png"
}
Pattern("gonearbytown2.png"):similar(0.3)
Pattern("69.png"):similar(0.3)
Pattern("fullinventory1.png"):similar(1)
Pattern("57.png"):similar(0.6)
Pattern("74.png"):similar(0.9)
search = {
abvHP = Region ( 914, 798, 520, 130 ),
xmark = Region ( 1004, 671, 350, 190 ),
xmark2 = Region ( 978, 711, 441, 98 ),
townmenu = Region ( 342, -50, 500, 500 ),
nearbytown = Region ( 525, 92, 1300, 900 ),
smiley = Region ( 793, 878, 220, 220 ),
gotogrocery = Region ( -33, -50, 500, 500 ),
opengrocery = Region ( 1800, 530, 600, 600 ),
selljunk = Region ( 1922, 850, 400, 200 ),
closecornerright = Region ( 2205, -8, 120, 120),
autopath1 = Region (1450, 479, 250, 140),
autopath2 = Region (1450, 627, 250, 140),
autopath3 = Region (1450, 780, 250, 140),
closepopups = Region ( 1622, 0, 700, 350 ),
UPRRightcorner = Region ( 1461, 0, 900, 120 ),
rightmenu = Region ( 1699, 100 , 631, 740 ),
underbs = Region ( 772, 883, 831, 144 ),
feedbs = Region ( 1016, 881, 1299, 169 ),
alertpopup = Region ( 662, 193, 997, 675 ),
UPRLeftcorner = Region ( 36, 3, 70, 70 ),
bsleft = Region ( 6, 272, 437, 660 ),
autoatk = Region ( 832, 932, 120, 120 ),
spoilcheck = Region ( 664, 176, 1143, 628 ),
pet1 = Region ( 1925, 357, 179, 77 ),
pet2 = Region ( 1925, 553, 179, 77 ),
pet3 = Region ( 1925, 749, 179, 77 ),
petfeed = Region ( 786, 925, 129, 149 ),
blackspiritskill = Region ( 1873, 493, 466, 141 ),
bsdropdown = Region ( 2149, 925, 157, 133 ),
questconfirm = Region ( 984, 847, 526 , 82 ),
checkdonequest = Region ( 1580, 190, 756, 332 ),
skillconfirm = Region ( 860, 690, 617, 151 )
}
--Image:R{table.search}
--function ClosePopUps()
function ClosePopUps()
if Image:R(search.closepopups):existsClick("97.png") then wait(1)
toast ("closing popup")
end
if Image:R(search.closepopups):existsClick("113.png") then wait(1)
toast ("closing popup")
end
if Image:R(search.closepopups):existsClick("78.png") then wait(1)
toast ("closing popup")
end
end
--end
function OpenTownMenu()
--snapshot()
if Image:R(search.townmenu):existsClick("opentownmenu.png") then
wait(1)
GoToTown()
else
ClosePopUps()
wait(1)
OpenTownMenu()
toast ("not found")
wait(1)
--ClosePopUps()
end
--usePreviousSnap(false)
end
function GoToTown()
if Image:R(search.nearbytown):existsClick("gonearbytown2.png") then
if Image:R(search.autoatk):exists("autoatk.png") then
waitVanish("autoatk.png")
end
toast ("going to town")
wait(1)
GoToGrocery()
else
toast ("something's not right")
wait(1)
ClosePopUps()
OpenTownMenu()
end
end
function GoToGrocery()
if Image:R(search.smiley):exists("69.png", 20) then
Image:R(search.gotogrocery):existsClick("63.png")
toast ("going to grocery")
wait(3)
CheckStillTravelling()
search.opengrocery:wait("80.png", 3)
OpenGrocery()
else
toast ("grocery not found")
end
end
function CheckStillTravelling()
--snapshot()
if Image:R(search.xmark2):exists("xmark.png")
then
waitVanish("2.png", 30)
end
--usePreviousSnap(false)
end
function OpenGrocery()
--search.opengrocery:wait("80.png" ,10)
if Image:R(search.opengrocery):existsClick("80.png", 10) then
Image:R(search.selljunk):existsClick("94.png")
heavyinvent = false
CloseAndFarmAgain()
end
end
function CloseAndFarmAgain()
if Image:R(search.closecornerright):existsClick("97.png") then
wait(1)
Image:R(search.townmenu):existsClick("opentownmenu.png")
Image:R(search.autopath1):existsClick("104.png")
CheckStillTravelling()
AutoAtk()
end
end
function AutoAtk()
if Image:R(search.smiley):exists("69.png") then
search.smiley:waitVanish("69.png", 60)
end
if Image:R(search.autoatk):exists("autoatk.png") then
CheckStillTravelling()
else
search.autoatk:wait("autoatk.png", 60)
CheckStillTravelling()
end
end
function Close()
Image:R(search.closecornerright):existsClick("97.png")
wait(1)
end
function OpenBlackSpiritMenu()
if Image:R(search.UPRRightcorner):existsClick("17.png") then
toast ("mainmenu opened")
wait(1)
Image:R(search.rightmenu):existsClick("21.png")
wait(1)
FeedBlackSpirit()
else toast ("not found")
wait(1)
--Image:R()
end
end
function FeedBlackSpirit()
if Image:R(search.underbs):existsClick("feeddarkenergy.png") then
wait(1)
Image:R(search.feedbs):existsClick ("autosel.png")
wait(0.5)
Image:R(search.feedbs):existsClick("absorbnow.png")
wait(0.5)
Image:R(search.alertpopup):existsClick("42.png")
wait(0.5)
Image:R(search.back):existsClick("back.png")
wait(1)
FuseLightstone()
--if
end
end
function FuseLightstone()
if Image:R(search.bsleft):existsClick("fuselightstone.png") then
Image:R(search.feedbs):existsClick("autofuse.png")
wait(1)
Image:R(search.alertpopup):existsClick("fuseconfirm.png")
wait(1)
if not Image:R(search.underbs):exists("stopautofuse.png") then
wait(1)
Image:R(search.UPRLeftcorner)existsClick("back.png")
end
wait(1)
Close()
UseSkillbooks()
end
end
function FeedPets()
if Image:R(search.UPRRightcorner):existsClick("17.png") then
wait(1)
Image:R(search.rightmenu):existsClick ("138.png")
wait(1)
CheckPetHunger()
end
end
function CheckPetHunger()
if Image:R(search.pet1):existsClick("146.png") then click(location(786, 925))
wait(1)
if Image:R(search.pet2):existsClick("146.png") then click(location(786, 925)) end
wait(1)
if Image:R(search.pet3):existsClick("146.png") then click(location(786, 925)) end
wait(1)
Close()
end
end
function SpoilsCheck()
Image:H(50,50):R(search.spoilcheck):existsClick("152.png")
wait(0.2)
Image:R(search.spoilcheck):existsClick("152.png")
wait(0.2)
Image:H(50,50):R(search.spoilcheck):existsClick("164.png")
wait(0.2)
Image:R(search.spoilcheck):existsClick("164.png")
wait(0.2)
end
function UseSkillbooks()
if Image:R(search.UPRRightcorner):existsClick("20.png") then wait(1)
Image:R(search.selljunk):existsClick("5.png") wait(1)
Image:R(search.skillconfirm):existsClick("skillconfirm.png")
wait(10)
Close()
fullinvent = false
end
end
function CheckBlackSPSkills()
if Image:R(search.blackspiritskill):existsClick("bsskill1.png") then wait(10)
Image:R(search.blackspiritskill):existsClick("70.png")
wait(8)
Image:R(search.blackspiritskill):existsClick("74.png")
wait(6)
Image:R(search.blackspiritskill):existsClick("117.png")
wait(6)
else
if Image:R(search.blackspiritskill):existsClick("57.png") then wait(1)
Image:R(search.blackspiritskill):existsClick("bsskill1.png")
wait(10)
Image:R(search.blackspiritskill):existsClick("70.png")
wait(8)
Image:R(search.blackspiritskill):existsClick("74.png")
wait(6)
Image:R(search.blackspiritskill):existsClick("117.png")
wait(6)
else
toast ("black spirit skill not ready")
end
end
end
function CheckQuest()
if Image:R(search.checkdonequest):existsClick("77.png") then wait(2)
Image:R(search.selljunk):existsClick("51.png")
wait(2)
click(Location(2051, 373))
wait(0.5)
Image:R(search.questconfirm):existsClick("107.png")
wait(2)
click(Location(2051, 373))
else
dragDrop(Location(2051, 373), Location(2072, 8)) wait(2)
if Image:R(search.checkdonequest):existsClick("77.png") then
wait(2)
click(Location(2051, 373))
Image:R(search.selljunk):existsClick("51.png")
wait(2)
click(Location(2051, 373))
Image:R(search.questconfirm):existsClick("51.png")
wait(2)
click(Location(2051, 373))
dragDrop(Location(2067, 294),Location(2071, 645))
else
dragDrop(Location(2067, 294),Location(2071, 645))
end
end
end
while true do
--timer:set()
while (timer:check() <= 300) do
--OpenTownMenu()
-- SpoilsCheck()
if Image:R(search.abvHP):exists("fullinventory1.png")
then toast ("full inventory")
wait(1)
fullinvent = true
else
toast ("bag not yet full")
wait(1)
fullinvent = false
end
if fullinvent == true then OpenBlackSpiritMenu()
end
if Image:R(search.abvHP):exists("75.png")
then toast ("bag heavy")
wait(1)
heavyinvent1 = true
else
toast ("bag lightweight")
wait(1)
heavyinvent1 = false
end
if Image:R(search.abvHP):exists("1.png")
then toast ("bag heavy")
wait(1)
heavyinvent = true
else
toast ("bag lightweight")
wait(1)
heavyinvent = false
end
if heavyinvent == true then OpenTownMenu()
end
if heavyinvent1 == true then OpenTownMenu()
end
wait(1)
FeedPets()
wait(1)
--break
--end
--while (timer:check() <= 300) do
SpoilsCheck()
wait(1)
CheckBlackSPSkills()
wait(1)
-- CheckQuest()
--wait(1)
end
timer:set()
wait(2)
--while (timer:check() <= )
end
--usePreviousSnap(false)
--try()
--try2()
----- created by AnkuLua snap and play script ------
dofile(scriptPath() .. "DebugMyScript.luac")
Image:menu()
immersive = true
setImmersiveMode(immersive)
genVersion = "8.3.0-PRO2"
setAutoGameArea = true
pcall (autoGameArea, setAutoGameArea)
scriptDimension = 2340
Settings:setScriptDimension(true, scriptDimension)
Settings:setCompareDimension(true, scriptDimension)
ROOT = scriptPath()
DIR_IMAGES = ROOT .. "expImage"
setImagePath(DIR_IMAGES)
timeout = 2
local timer = Timer()
Settings:set("MinSimilarity", 0.7)
setDragDropStepCount(6)
setDragDropStepInterval(100)
setScanInterval(0.3)
local fullinvent = {}
local heavyinvent = {}
local heavyinvent1 = {}
PopUps = {
"Close.png",
"Exit.png"
}
Pattern("gonearbytown2.png"):similar(0.3)
Pattern("69.png"):similar(0.3)
Pattern("fullinventory1.png"):similar(1)
Pattern("57.png"):similar(0.6)
Pattern("74.png"):similar(0.9)
search = {
abvHP = Region ( 914, 798, 520, 130 ),
xmark = Region ( 1004, 671, 350, 190 ),
xmark2 = Region ( 978, 711, 441, 98 ),
townmenu = Region ( 342, -50, 500, 500 ),
nearbytown = Region ( 525, 92, 1300, 900 ),
smiley = Region ( 793, 878, 220, 220 ),
gotogrocery = Region ( -33, -50, 500, 500 ),
opengrocery = Region ( 1800, 530, 600, 600 ),
selljunk = Region ( 1922, 850, 400, 200 ),
closecornerright = Region ( 2205, -8, 120, 120),
autopath1 = Region (1450, 479, 250, 140),
autopath2 = Region (1450, 627, 250, 140),
autopath3 = Region (1450, 780, 250, 140),
closepopups = Region ( 1622, 0, 700, 350 ),
UPRRightcorner = Region ( 1461, 0, 900, 120 ),
rightmenu = Region ( 1699, 100 , 631, 740 ),
underbs = Region ( 772, 883, 831, 144 ),
feedbs = Region ( 1016, 881, 1299, 169 ),
alertpopup = Region ( 662, 193, 997, 675 ),
UPRLeftcorner = Region ( 36, 3, 70, 70 ),
bsleft = Region ( 6, 272, 437, 660 ),
autoatk = Region ( 832, 932, 120, 120 ),
spoilcheck = Region ( 664, 176, 1143, 628 ),
pet1 = Region ( 1925, 357, 179, 77 ),
pet2 = Region ( 1925, 553, 179, 77 ),
pet3 = Region ( 1925, 749, 179, 77 ),
petfeed = Region ( 786, 925, 129, 149 ),
blackspiritskill = Region ( 1873, 493, 466, 141 ),
bsdropdown = Region ( 2149, 925, 157, 133 ),
questconfirm = Region ( 984, 847, 526 , 82 ),
checkdonequest = Region ( 1580, 190, 756, 332 ),
skillconfirm = Region ( 860, 690, 617, 151 )
}
--Image:R{table.search}
--function ClosePopUps()
function ClosePopUps()
if Image:R(search.closepopups):existsClick("97.png") then wait(1)
toast ("closing popup")
end
if Image:R(search.closepopups):existsClick("113.png") then wait(1)
toast ("closing popup")
end
if Image:R(search.closepopups):existsClick("78.png") then wait(1)
toast ("closing popup")
end
end
--end
function OpenTownMenu()
--snapshot()
if Image:R(search.townmenu):existsClick("opentownmenu.png") then
wait(1)
GoToTown()
else
ClosePopUps()
wait(1)
OpenTownMenu()
toast ("not found")
wait(1)
--ClosePopUps()
end
--usePreviousSnap(false)
end
function GoToTown()
if Image:R(search.nearbytown):existsClick("gonearbytown2.png") then
if Image:R(search.autoatk):exists("autoatk.png") then
waitVanish("autoatk.png")
end
toast ("going to town")
wait(1)
GoToGrocery()
else
toast ("something's not right")
wait(1)
ClosePopUps()
OpenTownMenu()
end
end
function GoToGrocery()
if Image:R(search.smiley):exists("69.png", 20) then
Image:R(search.gotogrocery):existsClick("63.png")
toast ("going to grocery")
wait(3)
CheckStillTravelling()
search.opengrocery:wait("80.png", 3)
OpenGrocery()
else
toast ("grocery not found")
end
end
function CheckStillTravelling()
--snapshot()
if Image:R(search.xmark2):exists("xmark.png")
then
waitVanish("2.png", 30)
end
--usePreviousSnap(false)
end
function OpenGrocery()
--search.opengrocery:wait("80.png" ,10)
if Image:R(search.opengrocery):existsClick("80.png", 10) then
Image:R(search.selljunk):existsClick("94.png")
heavyinvent = false
CloseAndFarmAgain()
end
end
function CloseAndFarmAgain()
if Image:R(search.closecornerright):existsClick("97.png") then
wait(1)
Image:R(search.townmenu):existsClick("opentownmenu.png")
Image:R(search.autopath1):existsClick("104.png")
CheckStillTravelling()
AutoAtk()
end
end
function AutoAtk()
if Image:R(search.smiley):exists("69.png") then
search.smiley:waitVanish("69.png", 60)
end
if Image:R(search.autoatk):exists("autoatk.png") then
CheckStillTravelling()
else
search.autoatk:wait("autoatk.png", 60)
CheckStillTravelling()
end
end
function Close()
Image:R(search.closecornerright):existsClick("97.png")
wait(1)
end
function OpenBlackSpiritMenu()
if Image:R(search.UPRRightcorner):existsClick("17.png") then
toast ("mainmenu opened")
wait(1)
Image:R(search.rightmenu):existsClick("21.png")
wait(1)
FeedBlackSpirit()
else toast ("not found")
wait(1)
--Image:R()
end
end
function FeedBlackSpirit()
if Image:R(search.underbs):existsClick("feeddarkenergy.png") then
wait(1)
Image:R(search.feedbs):existsClick ("autosel.png")
wait(0.5)
Image:R(search.feedbs):existsClick("absorbnow.png")
wait(0.5)
Image:R(search.alertpopup):existsClick("42.png")
wait(0.5)
Image:R(search.back):existsClick("back.png")
wait(1)
FuseLightstone()
--if
end
end
function FuseLightstone()
if Image:R(search.bsleft):existsClick("fuselightstone.png") then
Image:R(search.feedbs):existsClick("autofuse.png")
wait(1)
Image:R(search.alertpopup):existsClick("fuseconfirm.png")
wait(1)
if not Image:R(search.underbs):exists("stopautofuse.png") then
wait(1)
Image:R(search.UPRLeftcorner)existsClick("back.png")
end
wait(1)
Close()
UseSkillbooks()
end
end
function FeedPets()
if Image:R(search.UPRRightcorner):existsClick("17.png") then
wait(1)
Image:R(search.rightmenu):existsClick ("138.png")
wait(1)
CheckPetHunger()
end
end
function CheckPetHunger()
if Image:R(search.pet1):existsClick("146.png") then click(location(786, 925))
wait(1)
if Image:R(search.pet2):existsClick("146.png") then click(location(786, 925)) end
wait(1)
if Image:R(search.pet3):existsClick("146.png") then click(location(786, 925)) end
wait(1)
Close()
end
end
function SpoilsCheck()
Image:H(50,50):R(search.spoilcheck):existsClick("152.png")
wait(0.2)
Image:R(search.spoilcheck):existsClick("152.png")
wait(0.2)
Image:H(50,50):R(search.spoilcheck):existsClick("164.png")
wait(0.2)
Image:R(search.spoilcheck):existsClick("164.png")
wait(0.2)
end
function UseSkillbooks()
if Image:R(search.UPRRightcorner):existsClick("20.png") then wait(1)
Image:R(search.selljunk):existsClick("5.png") wait(1)
Image:R(search.skillconfirm):existsClick("skillconfirm.png")
wait(10)
Close()
fullinvent = false
end
end
function CheckBlackSPSkills()
if Image:R(search.blackspiritskill):existsClick("bsskill1.png") then wait(10)
Image:R(search.blackspiritskill):existsClick("70.png")
wait(8)
Image:R(search.blackspiritskill):existsClick("74.png")
wait(6)
Image:R(search.blackspiritskill):existsClick("117.png")
wait(6)
else
if Image:R(search.blackspiritskill):existsClick("57.png") then wait(1)
Image:R(search.blackspiritskill):existsClick("bsskill1.png")
wait(10)
Image:R(search.blackspiritskill):existsClick("70.png")
wait(8)
Image:R(search.blackspiritskill):existsClick("74.png")
wait(6)
Image:R(search.blackspiritskill):existsClick("117.png")
wait(6)
else
toast ("black spirit skill not ready")
end
end
end
function CheckQuest()
if Image:R(search.checkdonequest):existsClick("77.png") then wait(2)
Image:R(search.selljunk):existsClick("51.png")
wait(2)
click(Location(2051, 373))
wait(0.5)
Image:R(search.questconfirm):existsClick("107.png")
wait(2)
click(Location(2051, 373))
else
dragDrop(Location(2051, 373), Location(2072, 8)) wait(2)
if Image:R(search.checkdonequest):existsClick("77.png") then
wait(2)
click(Location(2051, 373))
Image:R(search.selljunk):existsClick("51.png")
wait(2)
click(Location(2051, 373))
Image:R(search.questconfirm):existsClick("51.png")
wait(2)
click(Location(2051, 373))
dragDrop(Location(2067, 294),Location(2071, 645))
else
dragDrop(Location(2067, 294),Location(2071, 645))
end
end
end
while true do
--timer:set()
while (timer:check() <= 300) do
--OpenTownMenu()
-- SpoilsCheck()
if Image:R(search.abvHP):exists("fullinventory1.png")
then toast ("full inventory")
wait(1)
fullinvent = true
else
toast ("bag not yet full")
wait(1)
fullinvent = false
end
if fullinvent == true then OpenBlackSpiritMenu()
end
if Image:R(search.abvHP):exists("75.png")
then toast ("bag heavy")
wait(1)
heavyinvent1 = true
else
toast ("bag lightweight")
wait(1)
heavyinvent1 = false
end
if Image:R(search.abvHP):exists("1.png")
then toast ("bag heavy")
wait(1)
heavyinvent = true
else
toast ("bag lightweight")
wait(1)
heavyinvent = false
end
if heavyinvent == true then OpenTownMenu()
end
if heavyinvent1 == true then OpenTownMenu()
end
wait(1)
FeedPets()
wait(1)
--break
--end
--while (timer:check() <= 300) do
SpoilsCheck()
wait(1)
CheckBlackSPSkills()
wait(1)
-- CheckQuest()
--wait(1)
end
timer:set()
wait(2)
--while (timer:check() <= )
end
--usePreviousSnap(false)
--try()
--try2()