Mac 下纯lua(一)


Lua 介绍


 

什么是lua - lua是一种跨平台开发脚本语言。


Lua 历史

学校 University of Rio de Janeiro

国家 巴西

作者 Roberto Ierusalimschy,Luiz Henrique Figueiredo Waldemar Celes

小组 计算机图形小组

公司 Petrobas

成长 Data-Entry-Language=》Sol==》Lua


 

Lua 时间线

1993 - 创建

1996 - Dr。Dobbs 的文章发表提及Lua,被世界所知


 

开始使用Lua

基本框架 : 平台 - Opengl -  应用层 - 框架 - Lua代码和资源


设置Lua

官网:http://www.lua.org


Mac和iOS

Mac 自带

iOS iLuaBox,Lua Console


Lua特性

Lua是作为C语言的一个库而实现,语言本身没有入口


Lua变量

字母数字下划线,第一位不能为数字

关键字

and break do else elseif end false for function if in local nil not or repeat return then true until while


Hello,Lua

Mac shell 输入lua回车

message = "Hello,lua"

print("Hello lua")

> print(1,2,3,4,5,"One") 

输出为 1   2   3   4   5   One


字符串

转义符 \b \t \v \r \n \\ \' \"

message = [[My name is John]]

message = 'My name is John';

message = "My name is John"


 

数值和类型

定义 int i; dim i as variant;

类型

nil 空值 boolean 布尔值 number 数字 string 字符串 function 函数 userdata c分配的内存块 thread 线程 table 

first class functions 作为函数参数的函数


 

代码块和范围

global local


 

Lua运算符

算数运算符 + - * / %(余数) ^(指数) -(负数)

关系运算符 == ~= < > <= >=

逻辑运算符 and or not

连接符号 ..

长度符号 #

print(#"This is a test");//得出字符串长度


 

 

 

posted @ 2015-12-12 17:30  风林火山战  阅读(251)  评论(0编辑  收藏  举报