# tutor-lua **Repository Path**: hollson/tutor-lua ## Basic Information - **Project Name**: tutor-lua - **Description**: tutor-luatutor-luatutor-luatutor-luatutor-lua - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-02-08 - **Last Updated**: 2024-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 一. 安装Lua **准备工作** ```shell # Linux编译依赖于以下组件 yum install -y libtermcap-devel ncurses-devel libevent-devel readline-devel ``` **编译安装** > 进入[Lua官网](http://www.lua.org/)下载Lua包、并可查看[安装说明](https://www.lua.org/manual/5.4/readme.html)。 ```shell curl -R -O http://www.lua.org/ftp/lua-5.4.6.tar.gz tar zxf lua-5.4.6.tar.gz cd lua-5.4.6 make # 编译(根据当前系统自动交叉编译) make pc # 查看pkg配置 make uninstall # 先卸载旧版本 sudo make install # 安装(bin、inc和lib等) # 查看版本信息 $ ./src/lua -v Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio $ ./src/luac -v Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio ``` _警告 ⚠️:勿要卸载系统自带的Lua,yum等工具会依赖于它。_ **Windows安装** > 参考: https://github.com/rjpcomputing/luaforwindows
## 二. HelloWorld **交互模式** ```shell $ lua Lua 5.4.6 Copyright (C) 1994-2021 Lua.org, PUC-Rio > print("Hello World") Hello World > os.exit() ``` **脚本模式** - 编辑:`vim hello.lua` ```lua print("Hello World") ``` ```shell # 运行lua脚本 $ lua ./hello.lua Hello World ``` ## 三. 配置VsCode **插件** - Lua - Lua Debug - Code Runner ## 四. Lua包管理 ```shell luarocks install luasql-mysql ``` https://www.codenong.com/cs110780708/ https://www.jianshu.com/p/29ef7e4f667b ## 参考链接 http://luarocks.github.io/luarocks/releases/ https://www.runoob.com/lua/lua-tutorial.html