Post by Morgaine le Fay on Sept 15, 2019 10:48:54 GMT
Hi, I'm trying to make my first script but it don't work. I have a xiaomi mimax 3 with screen resolution of 2160x1080 and maybe this can cause some problem.
I highlighted the first region for check if is right and it seams to be correct., but the script dont click anything
I'm new of this language so please be patient with me
Here there are the screenshots of errors (two different errors depending on the use gems choice in user interface)
The script should click "battaglia" and then chose and opponent with 300 points or refresh the opponent list if not 300 (in future I would like to allow user to insert manually the minimum power level for choosing opponent). The script should also check if equipment is broken (rotto) and if so switch Equipment starting from nature element, then fire, water, light and death.
The script should run and cycle until energy is over or if user check use gems using gems to refill energy and fight until script stopped.
here is the script with image folder:
drive.google.com/file/d/1tYYlgL7BLADZhwPAGE4_rE0sULO-0_qm/view?usp=sharing
errors and pictures of what it should do:
drive.google.com/drive/folders/1KwAtg6IWF4N6do-arf6VqXBn6oCJej4g?usp=sharing
my script:
----- DH5 Arena Script ------
immersive = false
setAutoGameArea = true
pcall (autoGameArea, setAutoGameArea)
scriptDimension = 2160
Settings:setScriptDimension(true, scriptDimension)
Settings:setCompareDimension(true, scriptDimension)
rotto = 0
elemento = 1
usagemme = false
---regions---
battleRegion = Region(1460, 900, 500, 120)
rottoRegion = Region(870, 121, 120, 120)
coronaRegion = Region(1759, 300, 120, 120)
treRegion = Region(1840, 300, 120, 120)
aggiornaRegion = Region(318, 970, 200, 104)
okRegion = Region(1170, 810, 400, 110)
W1Region = Region(1630, 970, 340, 120)
rosaRegion = Region(780, 960, 150, 150)
elementRegion = Region(800, 330, 540, 540)
WRegion = Region(1500, 930, 400, 200)
VSRegion = Region(910, 360, 400, 220)
SRegion = Region(910, 360, 400, 220)
saltaRegion = Region(1600, 870, 400, 120)
corona2Region = Region(880, 300, 200, 200)
Vregion = Region(1880, 868, 300, 300)
continuaRegion = Region(1600, 930, 400, 120)
gemmeRegion = Region(1170, 810, 400, 110)
function userInterface()
dialogInit()
addTextView("Punteggio Minimo: ")
addEditText("minEnemyPower", "300")
newRow()
addTextView("")
newRow()
addTextView("usa Gemme")
addCheckBox("usagemme", "Usa Gemme per refill", false)
addTextView(" ")
dialogShow("Settaggi Script Arena")
end
function checkPower()
rosaRegion:wait("rosa.png")
Settings:setCompareDimension(true, scriptDimension)
local r = Region(1470,450,120,50)
local preSimilar = Settings:get("MinSimilarity")
Settings:set("MinSimilarity", 0.8)
local p = numberOCR(r,"power")
Settings:set("MinSimilarity", preSimilar)
Settings:setCompareDimension(true, 640)
-- Settings:snapSet("OutputRegImg", false)
return (p >= 1300)
end
function rotto()
rosaRegion:existsClick("rosa.png")
if elemento == 1 then
elementRegion:existsClick("foglia.png")
wait(2)
rotto = 0
elseif elemento == 2 then
elementRegion:existsClick("fuoco.png")
wait(2)
rotto = 0
elseif elemento == 3 then
elementRegion:existsClick("acqua.png")
wait(2)
rotto = 0
elseif elemento == 4 then
elementRegion:existsClick("luce.png")
wait(2)
rotto = 0
else
elementRegion:existsClick("morte.png")
wait(2)
rotto = 0
end
end
-- ========== main program ===========
do userInterface() end
while (true) do
battleRegion:highlight()
battleRegion:existsClick(Pattern("Battaglia.png"):similar(0.8))
battleRegion:highlightOff()
if (rottoRegion:exists("rotto.png", 3)) then
rotto = 1
else
rotto = 0
end
function punti()
coronaRegion:wait("corona1.png",15)
if (treRegion:exists("300.png")) then
treRegion:click("300.png")
else
wait (2)
aggiornaRegion:click("aggiorna.png")
okRegion:existsClick("ok.png")
do punti()
end
end
end
W1Region:existsClick("W1.png")
if (usagemme == true) then
gemmeRegion:click("gemme.png")
end
do checkPower() end
if (not checkPower()) then
elemento = elemento + 1
do rotto()
end
end
if (rotto == 1) then
do rotto() end
end
WRegion:existsClick("W.png")
VSRegion:existsClick("VS.png")
wait(2)
SRegion:click("S.png")
saltaRegion:existsClick("salta.png")
saltaRegion:click("salta.png")
corona2Region:click("corona2.png")
wait(2)
Vregion:click("V.png")
continuaRegion:existClick("continua.png")
end