Lua中的math.random坐标

我正在尝试检查屏幕上的颜色,如果颜色与我的预定字符串相同时,则要点击我在程序开头设置的变量。

math.randomseed(os.time())
xvar = (math.random(100) + 300)
yvar = (math.random(100) + 560)

touch = function()
local color = getColor(300,560)
if color == 16711422 then
tap(xvar ..','.. yvar)
else
usleep(5000000)
collectgarbage()
touch()
end
end

touch()

当我运行它时,我会收到一个警告,指出颜色应该如何:

/Applications/AutoTouch.app/Extensions.lua:105: bad argument #2 to 'touchDown' (number expected, got string)

我知道我的语言很糟糕,我还在学习细节。有时,我的很多错误都直接来自无效的结构。

正确的代码是tap(x,y)。 我只是假设我可以输入我先前已注意到的全局变量。

点赞