Post by roastchicken on Nov 6, 2016 4:12:51 GMT
Hi,
I discovered AnkuLua a few weeks ago and I finally got around to attempting to create a bot for a game. Unfortunately I've run into a snag with using click() on a Region. I have the bot highlight a Region, click on it, and then unhighlight it. I highlight it so I can make sure the region is in the right place. It highlights the button I want, but then it must be clicking on the button right under it because I go to the wrong screen next.
Here is my code:
So my question is, how does the bot decide where to click when you tell it to click on a Region? Does it click in the center of it, or on a corner? I'm confused as to why it clicks on the wrong button because the "Open Case" button is also near other buttons but it gets clicked correctly.
Main screen, with the "Open Case" button:
Screen where it clicks the wrong button (I want it to click on "Use key" but it clicks on "Preview skins"):
I discovered AnkuLua a few weeks ago and I finally got around to attempting to create a bot for a game. Unfortunately I've run into a snag with using click() on a Region. I have the bot highlight a Region, click on it, and then unhighlight it. I highlight it so I can make sure the region is in the right place. It highlights the button I want, but then it must be clicking on the button right under it because I go to the wrong screen next.
Here is my code:
Settings:setCompareDimension( true, 1280 )
Settings:setScriptDimension( true, 1280 )
setImmersiveMode( true )
local openCase = Region( 139, 265, 1000, 119 )
local gammaCase2 = Region( 393, 80, 237, 229 )
local useKey = Region( 480, 466, 318, 92 )
local saveItem = Region( 971, 289, 261, 142 )
local discardItem = Region( 46, 289, 261, 142 )
local spinTime = 10 -- the time it takes from pressing the "Use key" button til the spinning stops and the item appears
local looping = true
function closeAd()
looping = false
print( "ad appeared" )
end
openCase:highlight()
openCase:existsClick( "openCase.png", 1 )
openCase:highlightOff()
gammaCase2:highlight()
gammaCase2:existsClick( "gammaCase2.png", 1 )
gammaCase2:highlightOff()
while looping do
if useKey:exists( "useKey.png", 1 ) then
useKey:highlight()
click( useKey )
useKey:highlightOff()
wait( spinTime )
if saveItem:exists( "saveItem.png", 1 ) then
saveItem:highlight()
click( saveItem )
saveItem:highlightOff()
else
closeAd()
end
else
closeAd()
end
end
So my question is, how does the bot decide where to click when you tell it to click on a Region? Does it click in the center of it, or on a corner? I'm confused as to why it clicks on the wrong button because the "Open Case" button is also near other buttons but it gets clicked correctly.
Main screen, with the "Open Case" button:
Screen where it clicks the wrong button (I want it to click on "Use key" but it clicks on "Preview skins"):