使用Lua 在VsCode 环境下 开发
需要使用到 Socket 、Http、Udp、Tcp 开发 都可以使用 C库 LuaSocket
先下载VSCode 插件以及 Lua 的Windows 运行环境:
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324141308778-263316725.png]()
Lua运行环境:
https://www.runoob.com/lua/lua-environment.html
安装 一路Next ,放到 ,会自己放到 :C:\Program Files (x86)\Lua\5.1 目录下
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324142529761-107566035-20220502002013343.png]()
下载 LuaSocket
http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324141506725-1272848071-20220502002009707.png]()
在自己的项目中创建个文件夹,然后将下载好的 luasocket-2.0.2 解压文件 全都放到 这个文件夹下。
以 创建 LuaSockts2007 文件夹 为例子:
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324142329087-1902929694-20220502002005023.png]()
然后再 点击,在我们建立的 VsCode 项目中 加入 Lua Debug 插件的调试 launch.json 配置文件
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324142756110-682347939.png]()
在 launch.json 文件中录入:
![img https://cdn.jsdelivr.net/gh/xinqinew/pic@main/img/341502-20200324143423143-888848508-20220502001957132.png]()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lua",
"request": "launch",
"name": "Launch",
"path": "${workspaceFolder}/LuaSockts2007/lua/?.lua;C:/Program Files (x86)/Lua/5.1/lua/?.lua;", //LuaSockts2007+系统Lua运行环境
"cpath": "${workspaceFolder}/LuaSockts2007/?.dll;C:/Program Files (x86)/Lua/5.1/clibs/?.dll;",
// "path": "C:/Program Files (x86)/Lua/5.1/lua/?.lua", //系统Lua运行环境
// "cpath": "C:/Program Files (x86)/Lua/5.1/clibs/?.dll",
"luaexe": "C:/Program Files (x86)/Lua/5.1/lua.exe",
// "luaexe": "${workspaceFolder}/LuaSockts2007/lua5.1.exe;",
// "program": "${workspaceFolder}/socketMain.lua",
"program": "${workspaceFolder}/socketHttpMain.lua",
}
]
}
|
此时便 可以使用 Luasocket 进行开发或者 调试了