Lua热更新(hotfix)
2016-07-04 11:20
447 查看
Lua热更新(hotfix)
(金庆的专栏)
hotfix
Lua 5.2/5.3 hotfix. Hot update functions and keep old data. https://github.com/jinq0123/hotfix
hotfix 实现了Lua热更新,仅对函数作替换,保留旧数据。
例如 test.lua:
local M = {}
local a = "old"
function M.get_a() return a end
return M
更新到
local M = {}
local a = "new"
function M.get_a() return a .. "_x" end
return M
运行
local hotfix = require("hotfix")
local test = hotfix.hotfix_module("test")
test.get_a() -- "old_x"
数据 a 作为函数的upvalue得到了保留,但是函数得到了更新。
可查看 test/main.lua 中的测试用例。
运行测试:
E:\Git\Lua\hotfix\test>d:\Tools\lua\lua53.exe
Lua 5.3.2 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require("main").run()
Test OK!
>
(金庆的专栏)
hotfix
Lua 5.2/5.3 hotfix. Hot update functions and keep old data. https://github.com/jinq0123/hotfix
hotfix 实现了Lua热更新,仅对函数作替换,保留旧数据。
例如 test.lua:
local M = {}
local a = "old"
function M.get_a() return a end
return M
更新到
local M = {}
local a = "new"
function M.get_a() return a .. "_x" end
return M
运行
local hotfix = require("hotfix")
local test = hotfix.hotfix_module("test")
test.get_a() -- "old_x"
数据 a 作为函数的upvalue得到了保留,但是函数得到了更新。
可查看 test/main.lua 中的测试用例。
运行测试:
E:\Git\Lua\hotfix\test>d:\Tools\lua\lua53.exe
Lua 5.3.2 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require("main").run()
Test OK!
>
相关文章推荐
- 游戏资源自动转换成Lua表
- UVALive 6697 - Homework Evaluation(dp,字符串匹配得分)
- Lua实现的栈、队列
- lae界面开发工具入门之介绍九--<lua脚本组件篇>
- ulua学习笔记1
- C语言调用Lua脚本
- lua 函数
- lua 小知识
- lua计算 字符串宽度(中文英文混合)
- lua loadfile dofile require
- 【记录】eLua初体验
- lua热更新都能更新什么
- LNK1104: 无法打开文件“lua51.lib”
- OpenResty学习笔记(八) lua高阶之面向对象编程
- 系列1—BabeLua入门
- do Lua语言学习(二) end
- Uniyt热更新——LuaFrameWork学习(二)按钮点击事件
- 纯lua脚本搜索算法优化
- mac-os关于Lua5.1的安装
- do Lua语言学习(一) end