init.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ------------------------------------------------------------------------------
  2. -- This file is registered as reloadable.
  3. ------------------------------------------------------------------------------
  4. -- Everything in the mod lives here.
  5. -- Note this unusual syntax: if this file is reloaded, the previous contents of the table are not erased.
  6. -- They may be overwritten.
  7. -- You can use this technique in your own mods as part of making them reloadable.
  8. reload = reload or {}
  9. reload.modpath = minetest.get_modpath("reload")
  10. dofile(reload.modpath .. "/config.lua")
  11. dofile(reload.modpath .. "/api.lua")
  12. dofile(reload.modpath .. "/chatcommands.lua")
  13. -- Allow chat messages sent by this mod to be customized.
  14. -- Usefull if you want to add coloring to the messages, etc.
  15. -- Prefer overriding this function in your own mod, instead of changing this one.
  16. -- Chat is only sent when a player uses a chatcommand.
  17. reload.chat_send_player = function(name, message)
  18. minetest.chat_send_player(name, message)
  19. end
  20. -- Allow log messages from this mod to be customized.
  21. -- Prefer overriding this function in your own mod, instead of changing this one.
  22. -- Note that log messages are only emitted when chatcommands are used.
  23. reload.log = function(level, message)
  24. minetest.log(level, message)
  25. end
  26. -- Register this mod itself as reloadable.
  27. -- This is the prototype for all registrations using this mod.
  28. -- Registrations should look something like this.
  29. if not reload.file_registered('reload:init') then
  30. reload.register_file('reload:init', reload.modpath .. '/init.lua', false)
  31. reload.register_file('reload:api', reload.modpath .. '/api.lua', false)
  32. reload.register_file('reload:chat', reload.modpath .. '/chatcommands.lua', false)
  33. reload.register_file('reload:config', reload.modpath .. '/config.lua', false)
  34. end