example.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. local schema = require "model.schema"
  2. local logger = require "logger"
  3. local stringify = require "stringify"
  4. local module_name = "exampledata"
  5. local _M = schema.new(module_name, {
  6. times = 0,
  7. stage = 0,
  8. })
  9. local REQUEST = {}
  10. local CMD = {}
  11. local MODULE = {}
  12. local THIS = {}
  13. local function func_ret(fname, character, args)
  14. local f = THIS[fname]
  15. if not f then
  16. logger.error("func_ret not fname:%s !!!", fname)
  17. return {errno = STD_ERR.COMMON_SYS_ERR}
  18. end
  19. local errno, ret = f(character, args)
  20. if errno ~= 0 then
  21. return {errno = errno}
  22. end
  23. ret = ret or {}
  24. ret.errno = 0
  25. return ret
  26. end
  27. function MODULE.list_request_interests() return REQUEST end
  28. function MODULE.list_command_interests() return CMD end
  29. -- TODO: 解析/升级模块数据 在这里把数据初始化好
  30. function MODULE.parse(character)
  31. local d = _M.load(character)
  32. end
  33. -- TODO: 侦听事件
  34. function MODULE.monitor(character)
  35. end
  36. -- TODO: 类似泰利的 prepare 接口
  37. function MODULE.launch(character)
  38. local d = _M.assert_get(character)
  39. local u = _M.assert_runtime(character)
  40. end
  41. -- TODO: 与客户端同步数据
  42. function MODULE.ready(character)
  43. local d = _M.assert_get(character)
  44. logger.test("%s:ready, %s", module_name, stringify(d or {}))
  45. end
  46. -- TODO: 玩家下线时的处理
  47. function MODULE.saybye(character)
  48. end
  49. return MODULE