Post by zenkrye on Nov 13, 2017 18:09:46 GMT
I am working on trying to optimize my code better by using Regions. I stated by setting a region to the variable r then call my click command with r:. Then I ran into an issue that I need to use an if-else statement which I did not know of a way to set r before the next else. Then I started to have to make separate variables for to store each region.
Is there there a cleaner way to setup variables for regions? I am thinking I should set them all at the beginning and not try to worry about setting them when I need them in the logic. Or just using the hardcoded region instead of a variable.
Is there there a cleaner way to setup variables for regions? I am thinking I should set them all at the beginning and not try to worry about setting them when I need them in the logic. Or just using the hardcoded region instead of a variable.
r=Region(60, 963, 150, 150)
rQueueMax=Region(60, 963, 150, 150)
rMaxLimitOK=Region(285, 450, 150, 150)
rOccupy=Region(410, 502, 150, 150)
--r:waitClick("QueueMax.png")
if (existsClick("Attack.png",5)) then
waitVanish("Attack.png")
if (rQueueMax:existsClick("QueueMax.png",5)) then
r=Region(449, 965, 150, 150)
r:waitClick("March.png")
r:waitVanish("March.png")
elseif (rMaxLimitOK:existsClick("MaxLimitOK.png")) then
rMaxLimitOK:waitVanish("MaxLimitOK.png")
r=Region(583, 119, 150, 150)
r:waitClick("AttackCancel.png")
r:waitVanish("AttackCancel.png")
r=Region(-33, -40, 150, 150)
r:waitClick("EmpireCenter.png")
return
end
elseif (rOccupy:exists("Occupy.png")) then -- Farm not in location, skip: Flag to not attack again?
r= Region(554, 285, 150, 150)
r:waitClick("AttackCancel.png",3)
r:waitVanish("AttackCancel.png")
end