RepairRole.lua 889 B

1234567891011121314151617181920212223242526272829
  1. --- 用于修复角色数据
  2. --- Generated by EmmyLua(https://github.com/EmmyLua)
  3. --- Created by 無心道(15388152619).
  4. --- DateTime: 2024/12/11 14:20
  5. ---
  6. RepairRoleData = {}
  7. --- 修复角色数据
  8. ---@param actor any 角色
  9. ---@param key string 数据key
  10. ---@param time number 时间戳
  11. ---@param fun function 回调函数
  12. function RepairRoleData.action(actor, key, time, fun, ...)
  13. gameDebug.assertTrue(type(time) == "number", "数据修复的标记必须是时间戳")
  14. local old = tonumber(getplaydef(actor, key) or 0)
  15. if old ~= time then
  16. fun(...)
  17. setplaydef(actor, key, time)
  18. info(actor, actor, "修复数据", key, time)
  19. end
  20. end
  21. local function test()
  22. -- 调用修复数据功能, 玩家 模块名字 调用时间戳, 回调函数
  23. RepairRoleData.action(actor, "test", 202412111423, function()
  24. end)
  25. end