mtmock.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. mtmock = {}
  2. mtmock.mod_storage = {}
  3. dofile('mtmock.conf')
  4. dofile('mocks/settings.lua')
  5. dofile('mocks/inventory.lua')
  6. dofile('mocks/player.lua')
  7. mtmock.settings = SettingsMock:new()
  8. -- bind minetest and core aliases and
  9. -- work with minetest alias from here on
  10. minetest = mtmock
  11. core = mtmock
  12. --[[ //////////////////// CORE STUBS -- BEGIN \\\\\\\\\\\\\\\\\\\\ ]]--
  13. function core.get_builtin_path()
  14. return core.SCRIPTDIR
  15. end
  16. function core.register_on_joinplayer(join_fun)
  17. end
  18. function core.register_on_leaveplayer(leave_fun)
  19. end
  20. function core.translate(textdomain, text, ...)
  21. return text
  22. end
  23. function core.get_translator(textdomain)
  24. return function(str, ...) return core.translate("", str, ...) end
  25. end
  26. function core.set_http_api_lua(fun)
  27. end
  28. --[[ \\\\\\\\\\\\\\\\\\\\ CORE STUBS -- END //////////////////// ]]--
  29. --[[ //////////////////// MTMOCK API -- BEGIN \\\\\\\\\\\\\\\\\\\\ ]]--
  30. function mtmock.add_player(pl_name, is_builder)
  31. player = PlayerMock:new(pl_name, is_builder)
  32. minetest.connected_players[pl_name] = player
  33. return player
  34. end
  35. --[[ \\\\\\\\\\\\\\\\\\\\ MTMOCK API -- END //////////////////// ]]--
  36. -- load MT's serialize functions
  37. dofile(core.get_builtin_path() .. 'common/serialize.lua')
  38. dofile(core.get_builtin_path() .. 'game/misc.lua')
  39. minetest.connected_players = {}
  40. minetest.worldpath = mtmock.WORLDDIR
  41. function minetest.get_worldpath()
  42. return minetest.worldpath
  43. end
  44. function minetest.get_connected_players()
  45. return minetest.connected_players
  46. end
  47. function minetest.get_player_by_name(pl_name)
  48. local player = minetest.connected_players[pl_name]
  49. return player
  50. end
  51. function minetest.log(type, msg)
  52. end
  53. function minetest.register_on_chat_message(fun)
  54. end
  55. function minetest.register_chatcommand(cmd, def)
  56. end
  57. function minetest.setting_get_pos(setting)
  58. if mtmock.settings[setting] then
  59. return mtmock.settings[setting]
  60. else
  61. return nil
  62. end
  63. end
  64. function minetest.get_mod_storage()
  65. return mtmock.mod_storage
  66. end
  67. function minetest.get_player_privs(pl_name)
  68. if pl_name == nil or minetest.privs == nil then return nil end
  69. return minetest.privs[pl_name]
  70. end
  71. function minetest.set_player_privs(pl_name, pl_privs)
  72. if pl_name ~= nil and minetest.privs ~= nil then
  73. minetest.privs[pl_name] = pl_privs
  74. end
  75. end
  76. return mtmock