15,979
社区成员
发帖
与我相关
我的任务
分享
-- write log to the list of host, maximum log length is 4095
-- log will be truncated after index 4095
logToHost("SCRIPT_START")
-- set the interval between two steps, between 50 and 3000(ms)
-- the host will sleep a period after each move, 500 is the
-- default value for human in host.
setStepInterval(500);
-- slide to left, right, up, down
-- possible returns: SUCCESS, KEY_IGNORED, GAME_ISOVER
moveLeft()
moveUp()
moveRight()
moveDown()
-- sleep some time, in milliseconds
sleep(1000)
-- test if able to slide to a direction
-- possible returns:
-- true - able to slide
-- false - not able to slide
testMoveLeft()
testMoveUp()
testMoveRight()
testMoveDown()
-- get the cell values from host, the table index is from 0
cellValues = getCellTable();
-- loop through all table values and write to log
for i=0, #cellValues do
logToHost( string.format("CELL_VALUES[%d] = %d", i, cellValues[i]) )
end
-- get single cell value by index
-- possible returns:
-- nil - index is out of range
valueAtIndexZero = getCellValue(0)
-- get rows, columns
rows = getRows()
columns = getColumns()
-- get empty cell count
emptyCellCount = getEmptyCellCount()
-- test if game is over
if ( not isGameOver() ) then
logToHost("Game is not over.")
end