Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. function keyNum()
  2. local preMinSimilarity = Settings:get("MinSimilarity")
  3. Settings:set("MinSimilarity", 0.7)
  4. local anchor = low:wait("slash.png")
  5. -- local charx = keyPre:find("charx.png")
  6. local numRegion = Region(anchor:getX() - 50, anchor:getY(), 50, anchor:getH())
  7. numRegion:highlight(1)
  8. local num = numberOCRNoFindException(numRegion, "vFlash")
  9. Settings:set("MinSimilarity", preMinSimilarity)
  10. return(num)
  11. end
  12.  
  13. -- ========== Settings ================
  14. Settings:setCompareDimension(true, 1196)
  15. Settings:setScriptDimension(true, 1196)
  16. Settings:set("MinSimilarity", 0.8)
  17. localPath = scriptPath()
  18. dofile(localPath.."lib/commonLib.lua")
  19. setImmersiveMode(false)
  20. dimension = autoResize(Pattern("bigFlash.png"):similar(0.9), 1196, false)
  21. if (dimension < 0) then
  22. simpleDialog("Error", "cannot find correct compare dimension")
  23. return
  24. end
  25. toast (""..dimension)
  26. -- ========== main program ===========
  27. upperRight = Region(640, 0, 640, 350)
  28. right = Region(640, 0, 640, 800)
  29. left = Region(0, 0, 640, 800)
  30. upper = Region(0, 0, 1280, 380)
  31. low = Region(0, 360, 1280, 440)
  32.  
  33. skip = Location(640, 200)
  34.  
  35. dialogInit()
  36. addCheckBox("nextArea", "Goto next area", true)
  37. dialogShow("Choose goto next area or not after winning this stage")
  38. language = getLanguage()
  39.  
  40. acquirePng = "acquire."..language..".png"
  41. confirmPng = "confirm."..language..".png"
  42.  
  43. clickList = {Pattern("defeatedDiamond.png"):similar(0.9), "worldMap.png", "bigFlash.png",
  44. Pattern("Sell.png"):similar(0.9),Pattern("cancel2.png"):targetOffset(-3,-40), Pattern("cancelLong.png"):targetOffset(122,10),
  45. "box.png", "cancel.png", Pattern("victoryDiamond.png"):targetOffset(-85,-185), --confirmPng,
  46. "victoryFlash.png", "levelupFlash.png", "play.png"}
  47. -- "award.png",
  48. if (nextArea) then
  49. table.insert(clickList, "ilin.png")
  50. table.insert(clickList, "libia.png")
  51. table.insert(clickList, "dulander.png")
  52. end
  53.  
  54. if (nextArea) then flashRequireRegion = right else flashRequireRegion = left end
  55.  
  56. bigCancel = find("bigCancel.png")
  57. skip = Location(bigCancel:getX()- bigCancel:getW(), bigCancel:getY() + bigCancel:getH())
  58. click("bigFlash.png")
  59. existsClick("play.png", 10)
  60.  
  61. while (true) do
  62. local choice, listMatch = waitMulti(clickList, 5*60, skip)
  63. if (choice == -1) then
  64. simpleDialog("Warning", "Unknown happened\nReport to ankulua@gmail.com")
  65. return
  66. end
  67.  
  68. listMatch:highlight(1)
  69. if (choice > 2) then click(listMatch) end
  70. if (choice == 1) then
  71. getLastMatch():highlight(1)
  72. if (exists(Pattern("defeatedDiamond.png"):similar(0.9), 0.9)) then
  73. simpleDialog("Warning", "Lose")
  74. return
  75. end
  76. end
  77.  
  78. if (clickList[choice] == "box.png") then
  79. existsClick(Pattern("Sell.png"):similar(0.9), 2)
  80. existsClick(Pattern("cancel.png"):similar(0.8), 3)
  81. end
  82.  
  83. if (clickList[choice] == "ilin.png" or clickList[choice] == "libia.png" or clickList[choice] == "dulander.png") then
  84. while (existsClick(clickList[choice], 0)) do
  85. wait(1)
  86. end
  87. end
  88.  
  89. if (choice == 2 and exists("worldMap.png", 0)) then -- next round
  90. if (nextArea and flashRequireRegion:exists("require0.png",0)) then
  91. simpleDialog("Warning", "Reach end of curent area.")
  92. return
  93. end
  94.  
  95. local requiredFlash = existsMultiMax(flashRequireRegion,
  96. {"require3.png", "require4.png", "require5.png", "require6.png", "require7.png", "require8.png"})
  97. if (requiredFlash == -1) then requiredFlash = 9 else requiredFlash = requiredFlash + 2 end
  98. toast("required Flash = "..requiredFlash)
  99. while (true) do
  100. flashNum = keyNum()
  101. if (flashNum < 0) then break end
  102. if ( flashNum < requiredFlash) then
  103. toast("Not enough flash, wait 5 minutes")
  104. wait(5*60)
  105.  
  106. else
  107. toast(flashNum.." flashes")
  108. flashRequireRegion:click("smallFlash.png")
  109. break
  110. end
  111. end
  112. end
  113.  
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement