2
0

deprecated.lua 1.6 KB

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