实例介绍
【实例简介】
【实例截图】
【核心代码】
目录 Lua 5.3 参考手册..................................1 1 – 简介........................................................19 2 – 基本概念....................................................20 2.1 – 值与类型..............................................20 2.2 – 环境与全局环境........................................22 2.3 – 错误处理..............................................23 2.4 – 元表及元方法..........................................24 2.5 – 垃圾收集..............................................27 2.5.1 – 垃圾收集元方法..................................28 2.5.2 – 弱表............................................29 2.6 – 协程..................................................30 3 – 语言定义....................................................32 3.1 – 词法约定..............................................32 3.2 – 变量..................................................35 3.3 – 语句..................................................36 3.3.1 – 语句块..........................................36 3.3.2 – 代码块..........................................37 3.3.3 – 赋值............................................37 4.6 – C 中的错误处理........................................59 4.7 – C 中的让出处理........................................59 4.8 – 函数和类型............................................62 lua_absindex ...........................................62 lua_Alloc................................................62 lua_arith................................................64 lua_atpanic .............................................64 lua_call .................................................65 lua_callk................................................66 lua_CFunction ..........................................66 lua_checkstack .........................................67 lua_close ...............................................67 lua_compare............................................68 lua_concat..............................................68 lua_copy................................................69 lua_createtable .........................................69 lua_dump...............................................69 lua_error ...............................................70 lua_gc ..................................................70 lua_getallocf............................................71 lua_getfield.............................................71 lua_getextraspace ......................................71 lua_getglobal ...........................................72 lua_geti ................................................72 lua_getmetatable .......................................72 lua_gettable ............................................73 lua_gettop..............................................73 lua_getuservalue .......................................73 lua_insert...............................................73 lua_Integer .............................................74 lua_isboolean...........................................74 lua_iscfunction .........................................74 lua_isfunction...........................................75 lua_isinteger............................................75 lua_islightuserdata .....................................75 lua_isnil ................................................75 lua_isnone..............................................76 lua_isnoneornil .........................................76 lua_isnumber ...........................................76 lua_isstring .............................................76 lua_istable..............................................77 lua_isthread ............................................77 lua_isuserdata ..........................................77 lua_isyieldable..........................................77 lua_KContext ...........................................78 lua_KFunction ..........................................78 lua_len .................................................78 lua_load ................................................78 lua_newstate ...........................................79 lua_newtable ...........................................80 lua_newthread..........................................80 lua_newuserdata .......................................80 lua_next ................................................81 lua_Number ............................................81 lua_numbertointeger ...................................82 lua_pcall................................................82 lua_pcallk ..............................................83 lua_pop.................................................83 lua_pushboolean........................................84 lua_pushcclosure .......................................84 lua_pushcfunction ......................................84 lua_pushfstring .........................................85 lua_pushglobaltable ....................................85 lua_pushinteger ........................................86 lua_pushlightuserdata ..................................86 lua_pushliteral..........................................86 lua_pushlstring .........................................87 lua_pushnil .............................................87 lua_pushnumber...................... lua_pushstring..........................................87 lua_pushthread .........................................88 lua_pushvalue ..........................................88 lua_pushvfstring........................................88 lua_rawequal ...........................................89 lua_rawget .............................................89 lua_rawgeti .............................................89 lua_rawgetp ............................................89 lua_rawlen..............................................90 lua_rawset..............................................90 lua_rawseti .............................................90 lua_rawsetp ............................................91 lua_Reader .............................................91 lua_register.............................................91 lua_remove.............................................92 lua_replace .............................................92 lua_resume.............................................92 lua_rotate ..............................................93 lua_setallocf ............................................93 lua_setfield .............................................93 lua_setglobal ...........................................94 lua_seti.................................................94 lua_setmetatable .......................................94 lua_settable ............................................95 lua_settop ..............................................95 lua_setuservalue .......................................95 lua_State ...............................................95 lua_status ..............................................96 lua_stringtonumber.....................................96 lua_toboolean ..........................................97 lua_tocfunction .........................................97 lua_tointeger ...........................................97 lua_tointegerx ..........................................97 lua_tolstring ............................................98 lua_tonumber ..........................................98 lua_tonumberx .........................................99 lua_topointer ...........................................99 lua_tostring ............................................99 lua_tothread...........................................100 lua_touserdata ........................................100 lua_type ...............................................100 lua_typename .........................................100 lua_Unsigned ..........................................101 lua_upvalueindex ......................................101 lua_version ............................................101 lua_Writer .............................................101 lua_xmove.............................................102 lua_yield...............................................102 lua_yieldk .............................................102 4.9 – 调试接口.............................................103 lua_Debug.............................................103 lua_gethook ...........................................105 lua_gethookcount......................................105 lua_gethookmask......................................105 lua_getinfo ............................................106 lua_getlocal ...........................................107 lua_getstack...........................................107 lua_getupvalue ........................................108 lua_Hook ..............................................108 lua_sethook ...........................................109 lua_setlocal............................................110 lua_setupvalue ........................................110 lua_upvalueid..........................................110 lua_upvaluejoin........................................111 5 – 辅助库.....................................................111 5.1 – 函数和类型...........................................112 luaL_addchar ..........................................112 luaL_addlstring ........................................112 luaL_addsize...........................................112 luaL_addstring.........................................113 luaL_addvalue .........................................113 luaL_argcheck .........................................113 luaL_argerror ..........................................114 luaL_Buffer ............................................114 luaL_buffinit ...........................................115 luaL_buffinitsize .......................................115 luaL_callmeta..........................................115 luaL_checkany.........................................116 luaL_checkinteger .....................................116 luaL_checklstring ......................................116 luaL_checknumber.....................................116 luaL_checkoption ......................................117 luaL_checkstack .......................................117 luaL_checkstring.......................................118 luaL_checktype ........................................118 luaL_checkudata.......................................118 luaL_checkversion .....................................118 luaL_dofile................................. luaL_getmetafield......................................120 luaL_getmetatable .....................................121 luaL_getsubtable ......................................121 luaL_gsub .............................................121 luaL_len ...............................................122 luaL_loadbuffer ........................................122 luaL_loadbufferx.......................................122 luaL_loadfile ...........................................123 luaL_loadfilex..........................................123 luaL_loadstring ........................................123 luaL_newlib............................................124 luaL_newlibtable.......................................124 luaL_newmetatable ....................................124 luaL_newstate .........................................125 luaL_openlibs ..........................................125 luaL_optinteger ........................................125 luaL_optlstring.........................................126 luaL_optnumber .......................................126 luaL_optstring .........................................126 luaL_prepbuffer........................................127 luaL_prepbuffsize ......................................127 luaL_pushresult........................................127 luaL_pushresultsize....................................127 luaL_ref ...............................................128 luaL_Reg ..............................................128 luaL_requiref ..........................................128 luaL_setfuncs ..........................................129 luaL_setmetatable .....................................129 luaL_Stream...........................................129 luaL_testudata.........................................130 luaL_tolstring ..........................................130 luaL_traceback ........................................131 luaL_typename ........................................131 luaL_unref .............................................131 luaL_where ............................................131 6 – 标准库.....................................................132 6.1 – 基础函数.............................................133 assert (v [, message]) .................................133 collectgarbage ([opt [, arg]]) ..........................133 dofile ([filename]) .....................................134 error (message [, level])...............................134 _G.....................................................135 getmetatable (object) .................................135 ipairs (t) ...............................................135 load (chunk [, chunkname [, mode [, env]]]) ..........135 loadfile ([filename [, mode [, env]]]) ..................136 next (table [, index]) ..................................136 pairs (t) ...............................................137 pcall (f [, arg1, ···])....................................137 print (···) ..............................................137 rawequal (v1, v2)......................................137 rawget (table, index) ..................................138 rawlen (v) .............................................138 rawset (table, index, value)............................138 select (index, ···) ......................................138 setmetatable (table, metatable) .......................138 tonumber (e [, base]) .................................139 tostring (v) ............................................139 type (v) ...............................................139 _VERSION .............................................139 xpcall (f, msgh [, arg1, ···]) ...........................140 6.2 – 协程管理.............................................140 coroutine.create (f) ....................................140 coroutine.isyieldable () ................................140 coroutine.resume (co [, val1, ···]) .....................140 coroutine.running () ...................................141 coroutine.status (co)...................................141 coroutine.wrap (f) .....................................141 coroutine.yield (···) ....................................141 6.3 – 模块.................................................142 require (modname) ....................................142 package.config ........................................143 package.cpath .........................................143 package.loaded ........................................143 package.loadlib (libname, funcname) ..................143 package.path ..........................................144 package.preload .......................................144 package.searchers .....................................144 package.searchpath (name, path [, sep [, rep]]).......146 6.4 – 字符串处理...........................................146 string.byte (s [, i [, j]]) ................................147 string.char (···) ........................................147 string.dump (function [, strip]) ........................147 string.find (s, pattern [, init [, plain]]) .................148 string.format (formatstring, ···) ........................148 string.gmatch (s, pattern) .............................148 string.gsub (s, pattern, repl [, n]) .....................149 string.len (s) ..........................................150 string.lower (s) ........................................151 string.match (s, pattern [, init]) .......................151 string.pack (fmt, v1, v2, ···) ...........................151 string.packsize (fmt)...................................151 string.rep (s, n [, sep]) ................................151 string.reverse (s) ......................................151 string.sub (s, i [, j]) ...................................152 string.unpack (fmt, s [, pos]) ..........................152 string.upper (s)........................................152 6.4.1 – 匹配模式.......................................152 6.4.2 – 打包和解包用到的格式串.........................155 6.5 – UTF-8 支持...........................................156 utf8.char (···)..........................................157 utf8.charpattern .......................................157 utf8.codes (s) .........................................157 utf8.codepoint (s [, i [, j]]) ............................157 utf8.len (s [, i [, j]]) ...................................157 utf8.offset (s, n [, i]) ..................................158 6.6 – 表处理...............................................158 table.concat (list [, sep [, i [, j]]]) .....................158 table.insert (list, [pos,] value) .........................158 table.move (a1, f, e, t [,a2])...........................159 table.pack (···) ........................................159 table.remove (list [, pos]) .............................159 table.sort (list [, comp]) ...............................159 table.unpack (list [, i [, j]]) ............................160 6.7 – 数学函数.............................................160 math.abs (x) ..........................................160 math.acos (x) .........................................160 math.asin (x) ..........................................161 math.atan (y [, x]) ....................................161 math.ceil (x)...........................................161 math.cos (x)...........................................161 math.deg (x) ..........................................161 math.exp (x) ..........................................161 math.floor (x) .........................................161 math.fmod (x, y) ......................................162 math.huge.............................................162 math.log (x [, base]) ..................................162 math.max (x, ···) ......................................162 math.maxinteger ......................................162 math.min (x, ···).......................................162 math.mininteger.......................................162 math.modf (x) .........................................163 math.pi ................................................163 math.rad (x)...........................................163 math.random ([m [, n]]) ..............................163 math.randomseed (x) .................................163 math.sin (x) ...........................................163 math.sqrt (x) ..........................................164 math.tan (x)...........................................164 math.tointeger (x) .....................................164 math.type (x) .........................................164 math.ult (m, n) ........................................164 6.8 – 输入输出设施.........................................164 io.close ([file]).........................................165 io.flush ()..............................................165 io.input ([file]).........................................165 io.lines ([filename ···]).................................165 io.open (filename [, mode]) ...........................166 io.output ([file]) .......................................166 io.popen (prog [, mode]) ..............................167 io.read (···) ............................................167 io.tmpfile ()............................................167 io.type (obj) ...........................................167 io.write (···) ...........................................167 file:close () ............................................167 file:flush () ............................................168 file:lines (···) ..........................................168 file:read (···) ..........................................168 file:seek ([whence [, offset]]) .........................169 file:setvbuf (mode [, size]) ............................170 file:write (···) ..........................................170 6.9 – 操作系统设施.........................................170 os.clock () .............................................170 os.date ([format [, time]]).............................170 os.difftime (t2, t1) .....................................171 os.execute ([command]) ..............................171 os.exit ([code [, close]]) ...............................172 os.getenv (varname) ..................................172 os.remove (filename) ..................................172 os.rename (oldname, newname).......................172 os.setlocale (locale [, category]) .......................172 os.time ([table]) .......................................173 os.tmpname () ........................................173 6.10 – 调试库..............................................174 debug.debug () ........................................174 debug.gethook ([thread])..............................174 debug.getinfo ([thread,] f [, what]) ....................174 debug.getlocal ([thread,] f, local) ......................175 debug.getmetatable (value) ...........................175 debug.getregistry () ...................................176 debug.getupvalue (f, up) ..............................176 debug.getuservalue (u) ................................176 debug.sethook ([thread,] hook, mask [, count]) .......176 debug.setlocal ([thread,] level, local, value) ...........177 debug.setmetatable (value, table) .....................177 debug.setupvalue (f, up, value)........................177 debug.setuservalue (udata, value) .....................177 debug.traceback ([thread,] [message [, level]]) .......178 debug.upvalueid (f, n) .................................178 debug.upvaluejoin (f1, n1, f2, n2) .....................178 7 – 独立版 Lua.................................................178 8 – 与之前版本不兼容的地方.....................................181 8.1 – 语言的变更...........................................181 8.2 – 库的变更.............................................182 8.3 – API 的变更...........................................182 9 – Lua 的完整语法.............................................183
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论