2
0

deprecated.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --
  2. -- EnvRef
  3. --
  4. core.env = {}
  5. local envref_deprecation_message_printed = false
  6. setmetatable(core.env, {
  7. __index = function(table, key)
  8. if not envref_deprecation_message_printed then
  9. core.log("deprecated", "core.env:[...] is deprecated and should be replaced with core.[...]")
  10. envref_deprecation_message_printed = true
  11. end
  12. local func = core[key]
  13. if type(func) == "function" then
  14. rawset(table, key, function(self, ...)
  15. return func(...)
  16. end)
  17. else
  18. rawset(table, key, nil)
  19. end
  20. return rawget(table, key)
  21. end
  22. })
  23. function core.rollback_get_last_node_actor(pos, range, seconds)
  24. return core.rollback_get_node_actions(pos, range, seconds, 1)[1]
  25. end
  26. --
  27. -- core.setting_*
  28. --
  29. local settings = core.settings
  30. local function setting_proxy(name)
  31. return function(...)
  32. core.log("deprecated", "WARNING: core.setting_* "..
  33. "functions are deprecated. "..
  34. "Use methods on the core.settings object.")
  35. return settings[name](settings, ...)
  36. end
  37. end
  38. core.setting_set = setting_proxy("set")
  39. core.setting_get = setting_proxy("get")
  40. core.setting_setbool = setting_proxy("set_bool")
  41. core.setting_getbool = setting_proxy("get_bool")
  42. core.setting_save = setting_proxy("write")
  43. --
  44. -- core.register_on_auth_fail
  45. --
  46. function core.register_on_auth_fail(func)
  47. core.log("deprecated", "core.register_on_auth_fail " ..
  48. "is deprecated and should be replaced by " ..
  49. "core.register_on_authplayer instead.")
  50. core.register_on_authplayer(function (player_name, ip, is_success)
  51. if not is_success then
  52. func(player_name, ip)
  53. end
  54. end)
  55. end