Lua - getOrientation()throw尝试调用global(一个零值)

时间:2017-12-11 23:36:05

标签: ios lua autotouch

我正在尝试创建一个自动触摸脚本,根据屏幕方向点击2个不同的点。

这是我的剧本:

CREATE_TIME=2017-12-11-19-34-51;
SCREEN_SIZE="0x0";

touchDown(0, 182, 1329);
usleep(16000);
touchUp(0);

usleep(40000000);

local o = getOrientation();
alert(string.format("Screen orientation is : %d", 0))

-- Check for the close button's location
local o = getOrientation();

if o == 1 then
touchDown(0, 1016, 68);
usleep(16000);
touchUp(0);
log("Portrait");

else 
touchDown(0, 1000, 1818);
usleep(16000);
touchUp(0);
log("Landscape");

end;

usleep(40000000);
touchDown(0, 827, 1114);
usleep(16000);
touchUp(0);

usleep(1000);

问题是,在getOrientation的行上,我在日志文件中收到错误:尝试调用global' getOrientation' (零值)

有人可以帮我提一些建议吗?

1 个答案:

答案 0 :(得分:0)

您可以在不调用错误的情况下调用usleep和touchDown,这表明您正在使用的AutoTouch版本不支持getOrientation。

我在该函数中找到的唯一两件事是AutoTouch引用中的相应条目,其中包含错误的代码示例:

 local o = getOrientation();
 alert(string.format("Screen orientation is : %d", 0));

0应该o才有意义。

否则您将始终打印Screen orientation is :0

并且抱怨getOrientation()的人总是返回1,无论他做什么。

另外,在快速查看Autotouch网站时,我发现至少有3个死链接。他们网站上的最后一篇文章是从2016年8月开始的。

所以也许你最好别用别的东西。这个项目对我来说并不是很有希望。