|
Post by nearlydead07 on Aug 15, 2021 16:47:51 GMT
How can I make this script more efficient or faster? I need it to click the numbers in orange in the order that they appear. The white numbers do not change if the input is wrong and the orange numbers always appear in the same order. REG.shop = {
image_region1_0 = Region(447, 630, 70, 100),
image_region1_1 = Region(447, 630, 70, 100),
image_region1_2 = Region(447, 630, 70, 100),
image_region1_3 = Region(447, 630, 70, 100),
image_region1_4 = Region(447, 630, 70, 100),
image_region1_5 = Region(447, 630, 70, 100),
image_region1_6 = Region(447, 630, 70, 100),
image_region1_7 = Region(447, 630, 70, 100),
image_region1_8 = Region(447, 630, 70, 100),
image_region1_9 = Region(447, 630, 70, 100),
image_region2_0 = Region(503, 630, 72, 100),
image_region2_1 = Region(503, 630, 72, 100),
image_region2_2 = Region(503, 630, 72, 100),
image_region2_3 = Region(503, 630, 72, 100),
image_region2_4 = Region(503, 630, 72, 100),
image_region2_5 = Region(503, 630, 72, 100),
image_region2_6 = Region(503, 630, 72, 100),
image_region2_7 = Region(503, 630, 72, 100),
image_region2_8 = Region(503, 630, 72, 100),
image_region2_9 = Region(503, 630, 72, 100),
image_region3_0 = Region(560, 630, 80, 120),
image_region3_1 = Region(560, 630, 80, 120),
image_region3_2 = Region(560, 630, 80, 120),
image_region3_3 = Region(560, 630, 80, 120),
image_region3_4 = Region(560, 630, 80, 120),
image_region3_5 = Region(560, 630, 80, 120),
image_region3_6 = Region(560, 630, 80, 120),
image_region3_7 = Region(560, 630, 80, 120),
image_region3_8 = Region(560, 630, 80, 120),
image_region3_9 = Region(560, 630, 80, 120),
}
function shoplocation1()
if REG.shop.image_region1_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shoplocation2()
elseif REG.shop.image_region1_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shoplocation2()
elseif REG.shop.image_region1_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shoplocation2()
elseif REG.shop.image_region1_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shoplocation2()
elseif REG.shop.image_region1_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shoplocation2()
elseif REG.shop.image_region1_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shoplocation2()
elseif REG.shop.image_region1_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shoplocation2()
elseif REG.shop.image_region1_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shoplocation2()
elseif REG.shop.image_region1_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shoplocation2()
elseif REG.shop.image_region1_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shoplocation2()
else
toast("Not Found")
end end
function shoplocation2()
if REG.shop.image_region2_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shoplocation3()
elseif REG.shop.image_region2_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shoplocation3()
elseif REG.shop.image_region2_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shoplocation3()
elseif REG.shop.image_region2_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shoplocation3()
elseif REG.shop.image_region2_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shoplocation3()
elseif REG.shop.image_region2_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shoplocation3()
elseif REG.shop.image_region2_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shoplocation3()
elseif REG.shop.image_region2_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shoplocation3()
elseif REG.shop.image_region2_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shoplocation3()
elseif REG.shop.image_region2_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shoplocation3()
else
toast("Not Found")
end end
function shoplocation3()
if REG.shop.image_region3_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shopbuy()
elseif REG.shop.image_region3_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shopbuy()
elseif REG.shop.image_region3_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shopbuy()
elseif REG.shop.image_region3_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shopbuy()
elseif REG.shop.image_region3_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shopbuy()
elseif REG.shop.image_region3_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shopbuy()
elseif REG.shop.image_region3_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shopbuy()
elseif REG.shop.image_region3_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shopbuy()
elseif REG.shop.image_region3_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shopbuy()
elseif REG.shop.image_region3_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shopbuy()
else
toast("Not Found")
end end
function shopbuy()
wait (10)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (1)
click(Location(540, 1460))-- refresh shop
wait (3)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (3)
click(Location(1000, 470)) -- close shop
end
while true do
shoplocation1()
end
|
|
|
Post by AnkuLua on Aug 16, 2021 15:11:28 GMT
|
|
|
Post by Exilereven on Aug 16, 2021 16:47:00 GMT
How can I make this script more efficient or faster? I need it to click the numbers in orange in the order that they appear. The white numbers do not change if the input is wrong and the orange numbers always appear in the same order. REG.shop = {
image_region1_0 = Region(447, 630, 70, 100),
image_region1_1 = Region(447, 630, 70, 100),
image_region1_2 = Region(447, 630, 70, 100),
image_region1_3 = Region(447, 630, 70, 100),
image_region1_4 = Region(447, 630, 70, 100),
image_region1_5 = Region(447, 630, 70, 100),
image_region1_6 = Region(447, 630, 70, 100),
image_region1_7 = Region(447, 630, 70, 100),
image_region1_8 = Region(447, 630, 70, 100),
image_region1_9 = Region(447, 630, 70, 100),
image_region2_0 = Region(503, 630, 72, 100),
image_region2_1 = Region(503, 630, 72, 100),
image_region2_2 = Region(503, 630, 72, 100),
image_region2_3 = Region(503, 630, 72, 100),
image_region2_4 = Region(503, 630, 72, 100),
image_region2_5 = Region(503, 630, 72, 100),
image_region2_6 = Region(503, 630, 72, 100),
image_region2_7 = Region(503, 630, 72, 100),
image_region2_8 = Region(503, 630, 72, 100),
image_region2_9 = Region(503, 630, 72, 100),
image_region3_0 = Region(560, 630, 80, 120),
image_region3_1 = Region(560, 630, 80, 120),
image_region3_2 = Region(560, 630, 80, 120),
image_region3_3 = Region(560, 630, 80, 120),
image_region3_4 = Region(560, 630, 80, 120),
image_region3_5 = Region(560, 630, 80, 120),
image_region3_6 = Region(560, 630, 80, 120),
image_region3_7 = Region(560, 630, 80, 120),
image_region3_8 = Region(560, 630, 80, 120),
image_region3_9 = Region(560, 630, 80, 120),
}
function shoplocation1()
if REG.shop.image_region1_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shoplocation2()
elseif REG.shop.image_region1_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shoplocation2()
elseif REG.shop.image_region1_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shoplocation2()
elseif REG.shop.image_region1_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shoplocation2()
elseif REG.shop.image_region1_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shoplocation2()
elseif REG.shop.image_region1_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shoplocation2()
elseif REG.shop.image_region1_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shoplocation2()
elseif REG.shop.image_region1_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shoplocation2()
elseif REG.shop.image_region1_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shoplocation2()
elseif REG.shop.image_region1_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shoplocation2()
else
toast("Not Found")
end end
function shoplocation2()
if REG.shop.image_region2_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shoplocation3()
elseif REG.shop.image_region2_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shoplocation3()
elseif REG.shop.image_region2_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shoplocation3()
elseif REG.shop.image_region2_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shoplocation3()
elseif REG.shop.image_region2_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shoplocation3()
elseif REG.shop.image_region2_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shoplocation3()
elseif REG.shop.image_region2_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shoplocation3()
elseif REG.shop.image_region2_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shoplocation3()
elseif REG.shop.image_region2_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shoplocation3()
elseif REG.shop.image_region2_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shoplocation3()
else
toast("Not Found")
end end
function shoplocation3()
if REG.shop.image_region3_1:existsClick("1.png", 1) then
click(Location(200, 1010)) --1 location
shopbuy()
elseif REG.shop.image_region3_2:existsClick("2.png", 1) then
click(Location(375, 1010)) --2 location
shopbuy()
elseif REG.shop.image_region3_3:existsClick("3.png", 1) then
click(Location(540, 1010)) --3 location
shopbuy()
elseif REG.shop.image_region3_4:existsClick("4.png", 1) then
click(Location(715, 1010)) --4 location
shopbuy()
elseif REG.shop.image_region3_5:existsClick("5.png", 1) then
click(Location(875, 1010)) --5 location
shopbuy()
elseif REG.shop.image_region3_6:existsClick("6.png", 1) then
click(Location(200, 1175)) --6 location
shopbuy()
elseif REG.shop.image_region3_7:existsClick("7.png", 1) then
click(Location(375, 1175)) --7 location
shopbuy()
elseif REG.shop.image_region3_8:existsClick("8.png", 1) then
click(Location(540, 1175)) --8 location
shopbuy()
elseif REG.shop.image_region3_9:existsClick("9.png", 1) then
click(Location(715, 1175)) --9 location
shopbuy()
elseif REG.shop.image_region3_0:existsClick("0.png", 1) then
click(Location(875, 1175)) --0 location
shopbuy()
else
toast("Not Found")
end end
function shopbuy()
wait (10)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (1)
click(Location(540, 1460))-- refresh shop
wait (3)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (3)
click(Location(1000, 470)) -- close shop
end
while true do
shoplocation1()
end
REG = {} -- Ankulua TIMEOUT = 3 SIMILAR = 0.9 WIDTH = 1080 HEIGHT = 1920 --Sets root folder structure(so that it runs from whatever folder your script is ran from. ROOT = scriptPath() --Sets a custom path for my images folder, make sure your imagename.png is in yoyr images folder DIR_IMAGES = ROOT .. "image" DIR_LIBS = ROOT .. "libs/" setImagePath(DIR_IMAGES) -- Ankulua settings -- --------------------------------------- Settings:setCompareDimension(true, WIDTH) Settings:setScriptDimension(true, WIDTH) Settings:set("AutoWaitTimeout", TIMEOUT) Settings:set("MinSimilarity", SIMILAR) -- --this a collection of functions from ankulua members, it will pre-load and add a lot of extra/common functions for us to use. -- luaLib = loadstring(httpGet("https://raw.githubusercontent.com/mercobots/luaLib/master/luaLib.lua")) luaLib() commonLib = loadstring(httpGet("https://raw.githubusercontent.com/AnkuLua/commonLib/master/commonLib.lua")) commonLib() --be sure to set your Region(x,y,h,w) according to where YOU need to locate image. REG.image = { image_region1 = Region(545, 145, 85, 55), --H65.png image_region2 = Region(545, 145, 85, 55), --H66.png image_region3 = Region(545, 145, 85, 55), -- H67.png image_region4 = Region(455, 145, 175, 55), --H68.png image_regiongold = Region(738, 1004, 90, 90), -- gold image_regionfull = Region(309, 54, 70, 70), -- full gold } KEY = { --set Global Object Location(200, 1010), --keypad 1 Location(375, 1010), --keypad 2 Location(540, 1010), --keypad 3 Location(715, 1010), --keypad 4 Location(875, 1010), --keypad 5 Location(200, 1175), --keypad 6 Location(375, 1175), --keypad 7 Location(540, 1175), --keypad 8 Location(715, 1175), --keypad 9 Location(875, 1175), --keypad 0 } function GoldCheck() --first if, will look for our image.png for 1 second, change to whatever you need to kind of (wait) 3 secs looking for image, or 1 sec, etc... if REG.image.image_regiongold:existsClick("Gold.png", 1)then playMusic("pristine.mp3", false) action = 'click' wait (2) click(Location(530, 725)) elseif REG.image.image_regionfull:existsClick("Full.png", 1)then level() else toast ("No Gold bollocks") end end --end of GoldTest() function level() click(Location(230, 1830)) wait(2) click(Location(650, 1725)) click(Location(650, 1725)) click(Location(650, 1725)) click(Location(130, 875)) end function StageCheck() --first if, will look for our image.png for 1 second, change to whatever you need to kind of (wait) 3 secs looking for image, or 1 sec, etc.. if REG.image.image_region1:existsClick("H65.png", 1) then rebirth() elseif REG.image.image_region2:existsClick("H66.png", 1) then rebirth() elseif REG.image.image_region3:existsClick("H67.png", 1) then rebirth() elseif REG.image.image_region4:existsClick("H68.png", 1) then rebirth() else toast ("No Stage bollocks") end end --end of clickTest() function rebirth() playMusic("stage.mp3", false) click(Location(70, 715)) wait(2) click(Location(535, 1635)) wait(2) click(Location(550, 530)) wait(45) enterCode(shop_OCR()) end function shopbuy() wait (10) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (1) click(Location(540, 1460))-- refresh shop wait (3) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (3) click(Location(1000, 470)) -- close shop end function shop_OCR() local reg = Region(0,0,0,0) --make this region a square around the 4 digit code area local p = numberOCR(r,"button") -- put all of your number pictures, 1-9 and 0, in your image folder and rename each one like this button1.png,button2.png, etc.. if p ~= nil then return tostring(p) end end function enterCode(str) --for each digit in the string for digit in string.gmatch(str, "%d") do if digit == "0" then click(KEY[10]) elseif digit == "1" then click(KEY[1]) elseif digit == "2"then click(KEY[2]) elseif digit == "3" then click(KEY[3]) elseif digit == "4" then click(KEY[4]) elseif digit == "5" then click(KEY[5]) elseif digit == "6" then click(KEY[6]) elseif digit == "7" then click(KEY[7]) elseif digit == "8" then click(KEY[8]) elseif digit == "9" then click(KEY[9]) end end end -----Main Script Start----- while true do -- do this until image is found StageCheck() wait(2) GoldCheck() wait(2) end NOT TESTED! but i think what your going for is there . Make sure to change all your image names, and put in your REGION up there in the OCR function where your numbers appear on thescreen, you can make it a little bigger area, doesnt need to be right on the number, give it a little padding so it has "room to search" lol.
|
|
|
Post by nearlydead07 on Aug 16, 2021 18:22:12 GMT
I tested just the code required for matching the digits and it worked perfectly. How would I go about adding: function shopbuy() wait (10) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (1) click(Location(540, 1460))-- refresh shop wait (3) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (3) click(Location(1000, 470)) -- close shop end After is successfully inputs the matching numbers?
REG = {}
-- Ankulua
TIMEOUT = 3
SIMILAR = 0.9
WIDTH = 1080
HEIGHT = 1920
--Sets root folder structure(so that it runs from whatever folder your script is ran from.
ROOT = scriptPath()
--Sets a custom path for my images folder, make sure your imagename.png is in yoyr images folder
DIR_IMAGES = ROOT .. "image"
DIR_LIBS = ROOT .. "libs/"
setImagePath(DIR_IMAGES)
-- Ankulua settings
-- ---------------------------------------
Settings:setCompareDimension(true, WIDTH)
Settings:setScriptDimension(true, WIDTH)
Settings:set("AutoWaitTimeout", TIMEOUT)
Settings:set("MinSimilarity", SIMILAR)
--
--this a collection of functions from ankulua members, it will pre-load and add a lot of extra/common functions for us to use.
--
luaLib = loadstring(httpGet("https://raw.githubusercontent.com/mercobots/luaLib/master/luaLib.lua"))
luaLib()
commonLib = loadstring(httpGet("https://raw.githubusercontent.com/AnkuLua/commonLib/master/commonLib.lua"))
commonLib()
KEY = { --set Global Object
Location(200, 1010), --keypad 1
Location(375, 1010), --keypad 2
Location(540, 1010), --keypad 3
Location(715, 1010), --keypad 4
Location(875, 1010), --keypad 5
Location(200, 1175), --keypad 6
Location(375, 1175), --keypad 7
Location(540, 1175), --keypad 8
Location(715, 1175), --keypad 9
Location(875, 1175), --keypad 0
}
function rebirth()
playMusic("stage.mp3", false)
click(Location(70, 715))
wait(2)
click(Location(535, 1635))
wait(2)
click(Location(550, 530))
wait(45)
enterCode(shop_OCR())
end
function shopbuy() wait (10) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (1) click(Location(540, 1460))-- refresh shop wait (3) click(Location(235, 865))--free buy wait (1) click(Location(235, 865)) -- close free buy wait (3) click(Location(1000, 470)) -- close shop
end
function shop_OCR()
local reg = Region(430, 610, 220, 140) --make this region a square around the 4 digit code area
local p = numberOCR(r,"button") -- put all of your number pictures, 1-9 and 0, in your image folder and rename each one like this button1.png,button2.png, etc..
if p ~= nil then
return tostring(p)
end
end
function enterCode(str)
--for each digit in the string
for digit in string.gmatch(str, "%d") do
if digit == "0" then
click(KEY[10])
elseif digit == "1" then
click(KEY[1])
elseif digit == "2"then
click(KEY[2])
elseif digit == "3" then
click(KEY[3])
elseif digit == "4" then
click(KEY[4])
elseif digit == "5" then
click(KEY[5])
elseif digit == "6" then
click(KEY[6])
elseif digit == "7" then
click(KEY[7])
elseif digit == "8" then
click(KEY[8])
elseif digit == "9" then
click(KEY[9])
end
end
end
while true do
-- do this until image is found
rebirth()
wait(2)
end
|
|
|
Post by nearlydead07 on Aug 16, 2021 19:26:11 GMT
I added Nevermind I added the shopbuy() function just before the last end for the function and it worked
function enterCode(str)
--for each digit in the string
for digit in string.gmatch(str, "%d") do
if digit == "0" then
click(KEY[10])
elseif digit == "1" then
click(KEY[1])
elseif digit == "2"then
click(KEY[2])
elseif digit == "3" then
click(KEY[3])
elseif digit == "4" then
click(KEY[4])
elseif digit == "5" then
click(KEY[5])
elseif digit == "6" then
click(KEY[6])
elseif digit == "7" then
click(KEY[7])
elseif digit == "8" then
click(KEY[8])
elseif digit == "9" then
click(KEY[9])
end
end shopbuy() end
|
|
|
Post by Exilereven on Aug 16, 2021 19:39:35 GMT
Im glad you got it working!
|
|
|
Post by nearlydead07 on Aug 19, 2021 14:36:25 GMT
Update: Works well for the most part except if the 3 digit combination starts with a 0 then it doesn't input the 0 since it doesnt recognize the leading 0. i.e. if the combination is 081 it only inputs 81, or if it is 009 only 9. I've even had 000 an it did nothing. I was thinking that if string is less than 100 click the 0 button once and then the rest of the string and if the string is less than 10 click the 0 button twice and then the remainder of the string but I'm not sure how to add that comparison block.
REG = {}
-- Ankulua TIMEOUT = 3 SIMILAR = 0.9 WIDTH = 1080 HEIGHT = 1920
--Sets root folder structure(so that it runs from whatever folder your script is ran from. ROOT = scriptPath()
--Sets a custom path for my images folder, make sure your imagename.png is in yoyr images folder DIR_IMAGES = ROOT .. "image" DIR_LIBS = ROOT .. "libs/" setImagePath(DIR_IMAGES)
-- Ankulua settings -- --------------------------------------- Settings:setCompareDimension(true, WIDTH) Settings:setScriptDimension(true, WIDTH) Settings:set("AutoWaitTimeout", TIMEOUT) Settings:set("MinSimilarity", SIMILAR)
-- --this a collection of functions from ankulua members, it will pre-load and add a lot of extra/common functions for us to use. --
luaLib = loadstring(httpGet("https://raw.githubusercontent.com/mercobots/luaLib/master/luaLib.lua")) luaLib()
commonLib = loadstring(httpGet("https://raw.githubusercontent.com/AnkuLua/commonLib/master/commonLib.lua")) commonLib()
--be sure to set your Region(x,y,h,w) according to where YOU need to locate image. REG.image = { image_region1 = Region(400, 140, 285, 60), --VH11.png image_region2 = Region(400, 140, 285, 60), --VH12.png image_region3 = Region(400, 140, 285, 60), --VH15.png image_regiongold = Region(738, 1004, 90, 90), -- gold image_regionfull = Region(309, 54, 70, 70), -- full gold }
KEY = { --set Global Object
Location(200, 1010), --keypad 1
Location(375, 1010), --keypad 2
Location(540, 1010), --keypad 3
Location(715, 1010), --keypad 4
Location(875, 1010), --keypad 5
Location(200, 1175), --keypad 6
Location(375, 1175), --keypad 7
Location(540, 1175), --keypad 8
Location(715, 1175), --keypad 9
Location(875, 1175), --keypad 0
}
function StageCheck()
--first if, will look for our image.png for 1 second, change to whatever you need to kind of (wait) 3 secs looking for image, or 1 sec, etc..
if REG.image.image_region1:existsClick("VH11.png", .5) then
rebirth()
elseif REG.image.image_region2:existsClick("VH12.png", .5) then
rebirth()
elseif REG.image.image_region3:existsClick("VH15.png", .5) then
else
toast ("No Stage bollocks")
end end --end of StageCheck()
function GoldCheck()
--first if, will look for our image.png for 1 second, change to whatever you need to kind of (wait) 3 secs looking for image, or 1 sec, etc...
if REG.image.image_regiongold:existsClick("Gold.png", .5)then
playMusic("pristine.mp3", false)
action = 'click'
wait (2)
click(Location(530, 725))
else
toast ("No Gold bollocks")
end end --end of GoldTest()
function FullGold()
if REG.image.image_regionfull:existsClick("Full.png", 0.5)then
level()
else
toast ("Not Full") end end
function level()
click(Location(230, 1830))
wait(2)
click(Location(650, 1450))
click(Location(130, 875))
end
function rebirth()
playMusic("stage.mp3", false)
click(Location(70, 715))
wait(2)
click(Location(535, 1635))
wait(2)
click(Location(550, 650))
wait(35)
enterCode(shop_OCR())
end
function shopbuy()
wait (10)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (30)
click(Location(540, 1460))-- refresh shop
wait (3)
click(Location(235, 865))--free buy
wait (1)
click(Location(235, 865)) -- close free buy
wait (30)
click(Location(1000, 470)) -- close shop
end
function shop_OCR()
local reg = Region(430, 610, 220, 140) --make this region a square around the 4 digit code area
local p = numberOCR(r,"button") -- put all of your number pictures, 1-9 and 0, in your image folder and rename each one like this button1.png,button2.png, etc..
if p ~= nil then
return tostring(p)
end
end
function enterCode(str)
--for each digit in the string
for digit in string.gmatch(str, "%d") do
if digit == "0" then
click(KEY[10])
elseif digit == "1" then
click(KEY[1])
elseif digit == "2"then
click(KEY[2])
elseif digit == "3" then
click(KEY[3])
elseif digit == "4" then
click(KEY[4])
elseif digit == "5" then
click(KEY[5])
elseif digit == "6" then
click(KEY[6])
elseif digit == "7" then
click(KEY[7])
elseif digit == "8" then
click(KEY[8])
elseif digit == "9" then
click(KEY[9])
end toast(str) end toast(str) shopbuy() end
-----Main Script Start-----
while true do
-- do this until image is found
StageCheck()
wait(2)
FullGold()
wait(2)
GoldCheck()
wait(2)
end
|
|