zoukankan      html  css  js  c++  java
  • Unity之热更新:(二)Lua

    一、Lua保留关键词释义

    local :加在变量名前表示局部变量

    nil:表示一个无效值,未初始化的变量默认为nil,如果你想删除一个变量,只需要赋值为nil。在条件表达式中相当于false。

    and、or、not:逻辑运算符

    true、false:boolean类型。除了false和nil,其他都是true。

    if、then、elseif、else、end

    a=60
    if(a>=80) then
        print("Good")
    elseif (a>=60) then
        print("OK")
    else
        print("Bad")
    end

    while、do

    while(true) do
        print("*")
    end

    for、in:

    goto、break:循环控制语句

    function、return:函数,可以有多个返回值,可以接受可变数目的参数(...)

    repeat、until

    a=1
    repeat
        print(a)
        a=a+1
    until(a>5)

    注释-- 单行注释 --[[ ]] 多行注释

    其他运算符:..连接字符串  #返回字符串长度

    二、八种数据类型

    nil 无效值 对于全局变量和table,nil还有“删除”作用
    boolean 布尔型 falsenil是false,其他都是true
    number 双精度浮点数 Lua只有一种数字类型double
    string 字符串 可用双引号、单引号、方括号表示 html=[[<html></html>]]
    function 函数 Lua里函数可以存在变量里
    userdata 自定义类型  可以将C/C++的数据存储到Lua变量中调用
    thread 线程 Lua里主要的线程是协同程序coroutine
    table Lua里初始索引从1开始,表的索引可以是数字或字符串,表是可变长度的

    三、字符串

    四、table

    1. table 连接

    2.  插入、移除、排序

    3. 遍历

     五、标准库

    1. 数学运算函数

    math.abs math.max math.min math.mod math.pow math.sqrt
    math.sin math.cos math.tan math.asin math.acos math.atan
    math.atan2 math.rad math.ceil math.floor math.deg math.exp
    math.frecp math.ldexp math.log math.log10 math.random math.randomseed

    2. 字符和数字转换

     3. loadstring 和 assert

     4. dofile(filename)

     5. rawequal、rawget、rawset

  • 相关阅读:
    Min_25筛
    POJ-1068 Parencodings---模拟括号的配对
    POJ-3295 Tautology---栈+表达式求值
    POJ-2586 Y2K Accounting Bug贪心,区间盈利
    POJ-1328 Radar Installation--区间选点问题(贪心)
    POJ-2965 The Pilots Brothers' refrigerator---思维题
    POJ-1753 Flip Game---二进制枚举子集
    南阳OJ-2-括号配对问题---栈的应用
    hdu-1082 Matrix Chain Multiplication---栈的运用
    hdu-1237 简单计算器---中缀表达式转后缀表达式
  • 原文地址:https://www.cnblogs.com/tomatokely/p/15662238.html
Copyright © 2011-2022 走看看