Post by rajikhushi70 on Jun 21, 2017 6:02:10 GMT
Dear Sir,
Below is my script & Error,.. please Guide me
-- patterns
altar = Pattern("altar.png")
-- functions
function move_map(where)
where = where or math.randomseed(os.time())
local move = {
{
-- down
Location(350, 700),
Location(350, 150),
},
{
-- up
Location(350, 150),
Location(350, 700),
},
{
--left
Location(60, 560),
Location(560, 560),
},
{
--right
Location(560, 560),
Location(60, 560),
},
}
-- pick a random move
local move_to = math.random(1, #move)
toast(move_to)
swipe(move[move_to][1], move[move_to][2])
wait(3)
end
function search_map(num_try)
-- vars
num_try = 3
local timer_local = Timer()
-- for each try
for i = 1, num_try do
if exists(altar) then
toast(tostring(altar) .. " found after: " .. timer_local:check())
-- this will breack the infinite loop
return getLastMatch()
end
-- max try will return false
return false
end
local getaltar = function()
while true do
wait(3)
if altar then
toast("altarFound after: " .. t:check())
getLastMatch():highlight(3)
wait(1)
click(getLastMatch())
wait(2)
click(Location(215,910))
wait(2)
click(Location(530,1185))
wait(2)
click(Location(375,1185))
wait(2)
search_map()
else
move_map()
end
end
end
end
getaltar() -- error here
attempt to call global 'getaltar(a nil value)
stack traceback:
Below is my script & Error,.. please Guide me
-- patterns
altar = Pattern("altar.png")
-- functions
function move_map(where)
where = where or math.randomseed(os.time())
local move = {
{
-- down
Location(350, 700),
Location(350, 150),
},
{
-- up
Location(350, 150),
Location(350, 700),
},
{
--left
Location(60, 560),
Location(560, 560),
},
{
--right
Location(560, 560),
Location(60, 560),
},
}
-- pick a random move
local move_to = math.random(1, #move)
toast(move_to)
swipe(move[move_to][1], move[move_to][2])
wait(3)
end
function search_map(num_try)
-- vars
num_try = 3
local timer_local = Timer()
-- for each try
for i = 1, num_try do
if exists(altar) then
toast(tostring(altar) .. " found after: " .. timer_local:check())
-- this will breack the infinite loop
return getLastMatch()
end
-- max try will return false
return false
end
local getaltar = function()
while true do
wait(3)
if altar then
toast("altarFound after: " .. t:check())
getLastMatch():highlight(3)
wait(1)
click(getLastMatch())
wait(2)
click(Location(215,910))
wait(2)
click(Location(530,1185))
wait(2)
click(Location(375,1185))
wait(2)
search_map()
else
move_map()
end
end
end
end
getaltar() -- error here
attempt to call global 'getaltar(a nil value)
stack traceback: