简体   繁体   中英

Lua - getOrientation() throw Attempt to call global (a nil value)

I am trying to create an autotouch script that will tap 2 different points based on the screen orientation.

This is my script:

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);

The problem is that on the line with getOrientation i get an error in the log file: attempt to call global 'getOrientation' (a nil value)

Can someone help me with an advice?

The fact that you can call usleep and touchDown without invoking an error indicates that getOrientation is not supported by the AutoTouch version you're using.

The only two things I found on that function was the respective entry in the AutoTouch reference, which contains a wrong code example:

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

where 0 should be o to make any sense.

Otherwise you will always print Screen orientation is :0

and a guy complaining about getOrientation() always returning 1 no matter what he does.

Plus while having a quick look at the Autotouch website I found at least 3 dead links. The last post on their website is from August 2016.

So maybe you're better off using something else. This project doesn't look very promissing to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM