evild
New Member
Posts: 12
|
Post by evild on Dec 19, 2016 16:22:16 GMT
Hey guys!
How can I improve this code to make it faster ? It is working well but it taking to much time to click on "skip.png" after didn't found the other gems. I'm already using Media Projection for more speed.
Settings:setCompareDimension(true, 1280)
Settings:setScriptDimension(true, 1280)
gem = 0
repeat
if (exists("deepgblue.png")
or exists("deepggreen.png")
or exists("deepgpurple.png")
or exists("deepgred.png")
or exists("deepgyellow.png")
or exists("deepsblue.png")
or exists("deepsgreen.png")
or exists("deepspurple.png")
or exists("deepsred.png")
or exists("ggreen.png")
or exists("gred.png"))
then
gem = gem + 1
print("Gem found")
else
click("skip.png")
end
until (gem > 0)
|
|
|
Post by vampiredbr9 on Jan 11, 2017 17:28:53 GMT
Hi, to make the code faster, first find where on the screen the been gems would appear. Make a region for where they appear. There is a thread on how to make regions. Next do NameOfRegionHere:exists("gemName.png") Hope this helps
|
|
|
Post by vampiredbr9 on Jan 11, 2017 17:29:39 GMT
Also, you could lower the resolution of the images. I use 600
|
|
evild
New Member
Posts: 12
|
Post by evild on Feb 1, 2017 17:15:51 GMT
Hi, to make the code faster, first find where on the screen the been gems would appear. Make a region for where they appear. There is a thread on how to make regions. Next do NameOfRegionHere:exists("gemName.png") Hope this helps The problem is the gems can appear anywhere on the screen! I take out some gems from the code and now It is looking only for 5 kind of gems but still take so long. Let me explain you what I want with this script. I want to code it like Clash of Clans scripts do. Skip bases until found elixir or gold higher than X But It is another kind of game, I need to skip bases and look for one of these 5 kinds of gems! The problem is my script is taking about 18-20 seconds to finally know there is no gems and skip the base and restart the loop.
|
|
|
Post by AnkuLua on Feb 2, 2017 0:08:50 GMT
Two things to improve. 1. just compare each gem once. For example, exists("deepgblue.png", 0)
2. Use the same snapshot for comparing gem by usePreviousSnap()
Your code will become
Settings:setCompareDimension(true, 1280)
Settings:setScriptDimension(true, 1280)
gem = 0
repeat
exists("deepgblue.png", 0) usePrevisousSnap(true) if (exists("deepgblue.png", 0)
or exists("deepggreen.png", 0)
or exists("deepgpurple.png", 0)
or exists("deepgred.png", 0)
or exists("deepgyellow.png", 0)
or exists("deepsblue.png", 0)
or exists("deepsgreen.png", 0)
or exists("deepspurple.png", 0)
or exists("deepsred.png", 0)
or exists("ggreen.png", 0)
or exists("gred.png", 0) )
then
usePreviousSnap(false) gem = gem + 1
print("Gem found")
else
click("skip.png")
end usePreviousSnap(false) until (gem > 0)
|
|
|
Post by AnkuLua on Feb 2, 2017 0:56:12 GMT
|
|
evild
New Member
Posts: 12
|
Post by evild on Feb 3, 2017 20:42:51 GMT
Comparing once is really much more fast!
I just don't figure out how to use the UsePreviousSnap feature, help me to insert it on my new code version:
Settings:setCompareDimension(true, 1280) Settings:setScriptDimension(true, 1280)
gem = 0
repeat if (exists("deepgblue.png", 0) or exists("deepggreen.png", 0) or exists("deepgpurple.png", 0) or exists("deepgred.png", 0) or exists("deepgyellow.png", 0)) then gem = gem + 1 print("Gem found") playMusic("beep.mp3", true) else click("skip.png") end until (gem > 0) [/cpde]
|
|