IDEA+EmmyLua Lua开发环境搭建

IDEA安装EmmyLua插件,方便本地调试lua脚本

Posted by guanyang on 2021-11-12
Words 240 and Reading Time 1 Minutes
Viewed Times

IDEA安装EmmyLua插件

下载MoDebug

关键步骤(mac安装)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- 安装lua
brew install lua

-- 安装luarocks工具
brew install luarocks

-- 安装luasocket
luarocks install luasocket

-- 安装lua-cjson(可选)
luarocks install lua-cjson 2.1.0-1

-- 安装redis-lua(可选)
luarocks install redis-lua

远程调试

示例代码

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
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by gy.
--- DateTime: 2021/10/27 20:16
---

-- 调试配置相关代码,实际使用不需要 start--
--require("mobdebug").start()

local cjson = require 'cjson'
local redis = require 'redis'
local host = "127.0.0.1"
local port = 6379
client = redis.connect(host, port)

redis.call = function(cmd, ...)
return assert(load('return client:' .. string.lower(cmd) .. '(...)'))(...)
end
-- 调试配置相关代码,实际使用不需要 end--


local KEYS = { "test1", "test2" }
local ARGV = { "1", '{\"age\":\"23\",\"name\":\"test\"}' }

local value = redis.call("GET", "key1")
print(value)

local queueListRedisKey = KEYS[1]
print(queueListRedisKey)

local userInfoObj = cjson.decode(ARGV[2])
print(cjson.encode(userInfoObj))

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !

...

...

00:00
00:00