Lua编程基础
Lua 笔记
SongYuLong的博客
学无止境
展开
-
LUA 安装luasocket
安装luasocket1).Lua 模块的安装和部署工具 LuaRocks$sudo apt-get install luarocks #安装部署工具 LuaRocks$luarocks install luasocket2).源码下载编译、安装$git clone https://github.com/diegonehab/luasocket.git$cd luasocke...原创 2018-05-18 13:55:23 · 5124 阅读 · 0 评论 -
lua 随机数
时间取反再取要7位数值,设为随机数因子math.randomseed(tostring(os.time()):reverse():sub(1, 7))for i=1, 15 do print(math.random()) --产生0到1之间的随机数 print(math.random(1,10)) --产生1到100之间的随机数 end...原创 2018-12-27 20:53:58 · 2036 阅读 · 0 评论 -
arm linux lua移植
lua:lua home1.下载lua源码lua下载lua-5.3.4.tar.gz2.解压:tar xvf lua-5.3.4.tar.gz3.修改makefile and luaconf.h$修改 lua-5.3.4/Makefile#INSTALL_TOP= /usr/localINSTALL_TOP= $(shell pwd)/out #修改安装目录(当前目录...原创 2018-09-27 20:15:02 · 1084 阅读 · 0 评论 -
Lua socket dns
DNSName resolution functions return all information obtained from the resolver in a table of the form: resolved = { name = canonic-name, alias = alias-list, ip = ip-address-list } Note ...原创 2018-05-23 10:59:10 · 2182 阅读 · 0 评论 -
Lua 3 Expressions
3.1 Arithmetic Operators Lua supports the usual arithmetic operators: the binary ‘ + ’ (addition), ‘ - ’ (sub- traction), ‘ * ’ (multiplication), ‘ / ’ (division), ‘ ^ ’ (exponentiation), ‘ % ’ (mo...原创 2018-05-23 09:36:44 · 188 阅读 · 0 评论 -
Lua 2 Types and Values
There are eight basic types in Lua:nil, boolean, number, string, userdata, function, thread, and tableprint(type("Hello world")) --> stringprint(type(10.4 * 3)) --> numberprint(ty...原创 2018-05-23 09:21:23 · 302 阅读 · 0 评论 -
Lua 1 Getting started
注释单行注释:--这里是注释 多行注释:--[[ 一些注释--]]全局变了print(b) --> nilb = 10print(b) --> 10运行环境#!/usr/local/bin/lua#!/usr/bin/env lua命令行$lua -e "print(math.sin(12))"$lua -i -l...原创 2018-05-22 21:59:52 · 226 阅读 · 0 评论 -
Lua UTF-8 Support
UTF-8 SupportThis library provides basic support for UTF-8 encoding. It provides all its functions inside the table utf8. This library does not provide any support for Unicode other than the handlin...原创 2018-05-22 20:37:34 · 1966 阅读 · 0 评论 -
Lua table 操作
Table ManipulationThis library provides generic functions for table manipulation. It provides all its functions inside the table table.Remember that, whenever an operation needs the length of a ta...原创 2018-05-22 20:35:05 · 826 阅读 · 0 评论 -
Lua math库
Mathematical Functions This library provides basic mathematical functions. It provides all its functions and constants inside the table math. Functions with the annotation “integer/float” give intege...原创 2018-05-22 20:28:59 · 1720 阅读 · 0 评论 -
Lua io库
io.close([file])Equivalent to file:close(). Without a file, closes the default output file.io.flush ()Equivalent to io.output():flush().io.input ([file])When called with a file name, it open...原创 2018-05-22 20:26:23 · 352 阅读 · 0 评论 -
Lua os库
os:os.clockos.dateos.difftimeos.executeos.exitos.getenvos.removeos.renameos.setlocaleos.timeos.tmpnameos.clock:返回一个程序使用CPU时间的一个近似值#!/usr/local/bin/lualocal x = os.clock()print(...原创 2018-05-22 20:03:33 · 816 阅读 · 0 评论 -
Lua coroutine协程
coroutine:coroutine.create coroutine.isyieldablecoroutine.resume coroutine.running coroutine.statuscoroutine.wrap coroutine.yield (1)coroutine.create (func) 传入一个函数参数,用来创建协程。返回一个“thread”对...原创 2018-05-22 17:53:49 · 351 阅读 · 0 评论 -
Lua functions list
basic:_G_VERSIONassertcollectgarbagedofileerrorgetmetatableipairsloadloadfilenextpairspcallprintrawequalrawgetrawlenrawsetrequireselectsetmetatabletonumbertostringtypexpcall...原创 2018-05-22 11:34:21 · 366 阅读 · 0 评论 -
LUA luasocket
http://w3.impa.br/~diego/software/luasocket/reference.htmlDNS (in socket):toip, tohostname, gethostname.FTP:get, put.HTTP:request.LTN12:filter: chain, cycle.pump: all, step.sink: chain, ...原创 2018-05-18 15:08:26 · 885 阅读 · 0 评论 -
lua server/client
-- server.lualocal socket = require("socket")local host = "127.0.0.1"local port = "12345"local server = assert(socket.bind(host, port, 1024))server:settimeout(0)local client_tab = {}local conn...原创 2018-05-18 14:30:41 · 867 阅读 · 0 评论 -
lua data time
local getTime = os.date(“%c”);其中的%c可以是以下的一种:(注意大小写)%a abbreviated weekday name (e.g., Wed)%A full weekday name (e.g., Wednesday)%b abbreviated month name (e.g., Sep)%B full month name (e.g., ...原创 2018-12-24 15:58:01 · 407 阅读 · 0 评论