lua---编译与反编译

lua---编译与反编译

脚本举例(test.lua)

-- 单行注释
--[[
    多行注释
]]--

-- 变量声明
the_str = 'hello'  -- 也可以是双引号 "hello"
print(the_str)
the_len = string.len(the_str)
print(the_len)
the_num = 1 + 2
print(the_num)

-- 没有数组,只有table
mytable = {}
mytable.foo = "hello world"
mytable.bar = 1 + 2
print(mytable)

-- 函数示例
function sayhello(name)
    print("hello, "..name)
end

sayhello("alice")

编译

luac -o test_compiled test.lua

执行编译后的文件:

lua ./test_compiled

反编译

Unluac: https://sourceforge.net/projects/unluac/

运行前需要安装java环境:

sudo apt install openjdk-19-jre

运行示例:

java -jar unluac.jar test_compiled > test_decompiled.lua

反编译的结果不完全等同于原脚本,没有注释


2024/6/7

posted @   rvy  阅读(221)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示