zoukankan      html  css  js  c++  java
  • Lua常用封装方法

    Lua

    获取随机值

    --获取随机值,指定上限和下限
    function getRandom(min,max)
        -- 接收一个整数n作为随即序列的种子
        math.randomseed(os.time())
        ----然后不断产生随机数
        --[[
        for i=1, 5 do
         print(math.random(100))
        end]]--
        return math.random(min,max)
    end

    获取当前时间

    function getNow()
        local nowTime = os.date("%Y-%m-%d %H:%M:%S", os.time())
        -- print(nowTime)
        return nowTime
    end
    print(os.time())

    触动精灵常用封装方法

    根据坐标点击

    function click(x,y)
        if(x~= -1 and y~= -1)  -- 根据多点颜色区域模糊查色返回的结果
        then
            touchDown(x, y)   -- 点击事件
            mSleep(20)
            touchUp(x, y)
        end
        mSleep(1000)
    end

    改良

    -- 根据坐标点击
    function click(x,y)
        if(x~= -1 and y~= -1)  -- 根据多点颜色区域模糊查色返回的结果
        then
            touchDown(x, y)   -- 点击事件
            mSleep(getRandom(15,30))
            touchUp(x, y)
        end
        mSleep(getRandom(1000,3000))  -- 点击后等待一秒到三秒
    end
  • 相关阅读:
    hadoop运行mahout问题解决方法
    在cdh5.1.3中在mapreduce使用hbase
    scala-eclipse
    创建cloudera-cdh5本地yum源
    HttpClient 操作总结
    Java NIO 操作总结
    linux 操作总结
    白话机器学习
    Java(jdk1.7) 陷阱
    Weibo Crawler in Action
  • 原文地址:https://www.cnblogs.com/aeolian/p/10515995.html
Copyright © 2011-2022 走看看