zoukankan      html  css  js  c++  java
  • lua基础知识(基于RUNOOB总结)

    数据类型

    nil:无效值,相当于false

    boolean:

    number:(双精度浮点)

    string:字符串,单引号间的一串字符,双引号间的一串字符,[[ 与 ]] 间的一串字符。

    userdata:自定义类型

    function(自定义类型)

    thread :独立线程

    table:键值对,相当于字典,和数组的区别在与索引可以不是数字

    table.concat (table , 两字符串间的连接字符, start , end):连接字符串的函数

    table.insert (table, [pos,] value):在索引位置插入元素,不指定索引在末尾添加

    table.remove (table [, pos]):删除指定索引的元素,不指定索引在末尾添加

    table.sort (table [, comp]):对table排序

    变量

    print

    循环

    print

    流程控制

    print

    函数

    print

    运算符

    print

    字符串

    string.upper(argument):全部变成大写

    string.lower(argument):全部变成小写

    string.gsub(String,a,b,num)把a替换成b,num为替换次数,不填就是全部替换

    string.find(String,a,num)查找sting中的a字符串的位置,从num索引开始查找

    string.reverse(string)翻转string

    string.format(),返回一个类似print格式类似的字符串string.format("the value is:%d",4)-->the value is:4

    string.char(arg) 和 string.byte(arg[,int]),char和num的转化

    string.len(arg),计算字符串的长度,也可以用#字符串

    string.rep(string, n)返回字符串的n个拷贝

    ..:链接字符串

    string.gmatch(str, pattern):查找str中的pattern字符串

    string.match(str, pattern, init):返回str中的patern字符串,从init位置开始搜索

    数组

    见table,这里要注意数组的是从1索引开始的

    迭代器

    print

    print

    模块和包

    print

    元素

    print

    协同程序

    coroutine.create()     创建 coroutine,返回 coroutine, 传入参数是函数

    coroutine.resume()   重启 coroutine,和 create 配合使用返回值[ture/false,val1,val2...]

    coroutine.status()           查看 coroutine 的状态,返回状态:dead,suspended,running

    coroutine.wrap()       创建 coroutine,返回一个函数,直接调用,和 create 功能重复但有区别。

    coroutine.running()        返回正在跑的 coroutine,返回线程号,返回值[主ture/非主false]

    coroutine.yield()             挂起 coroutine,为suspended态这个和 resume 配合使用,可返回值。

    文件IO

    print

    错误处理

    print

    调试

    print

    垃圾回收

    print

    面向对象

    print

    数据库访问

    print

     

  • 相关阅读:
    asp中动态include的方法
    asp存储过程使用大全
    用vb6写asp组件的简单例子
    asp中遍历一些对象(request,session,Application)
    查看ASP Session 变量的小工具
    层不能跨框架(包括TEXTAREA)显示的解决办法
    保存远程图片到本地 同时取得第一张图片并创建缩略图
    使用.Net开发asp组件
    使用ASP在IIS创建WEB站点
    解析notes自带的rtf javaapplet编辑器
  • 原文地址:https://www.cnblogs.com/still-smile/p/13059974.html
Copyright © 2011-2022 走看看