init.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- Copyright (c) 2013-18 rubenwardy. MIT.
  2. -- Internationalization support.
  3. local S = minetest.get_translator(minetest.get_current_modname())
  4. -- The global award namespace
  5. awards = {
  6. show_mode = "hud",
  7. registered_awards = {},
  8. registered_triggers = {},
  9. on_unlock = {},
  10. translator = S,
  11. }
  12. -- Load files
  13. local modpath = minetest.get_modpath(minetest.get_current_modname()).."/src"
  14. dofile(modpath.."/data.lua")
  15. dofile(modpath.."/api_awards.lua")
  16. dofile(modpath.."/api_triggers.lua")
  17. dofile(modpath.."/chat_commands.lua")
  18. dofile(modpath.."/gui.lua")
  19. dofile(modpath.."/triggers.lua")
  20. -- Optionally add default awards.
  21. if minetest.settings:get_bool("awards.add_defaults", true) then
  22. dofile(modpath.."/awards.lua")
  23. end
  24. awards.load()
  25. minetest.register_on_shutdown(awards.save)
  26. local function check_save()
  27. awards.save()
  28. minetest.after(18, check_save)
  29. end
  30. minetest.after(8 * math.random() + 10, check_save)
  31. -- Backwards compatibility
  32. awards.give_achievement = awards.unlock
  33. awards.getFormspec = awards.get_formspec
  34. awards.showto = awards.show_to
  35. awards.register_onDig = awards.register_on_dig
  36. awards.register_onPlace = awards.register_on_place
  37. awards.register_onDeath = awards.register_on_death
  38. awards.register_onChat = awards.register_on_chat
  39. awards.register_onJoin = awards.register_on_join
  40. awards.register_onCraft = awards.register_on_craft
  41. awards.def = awards.registered_awards
  42. awards.register_achievement = awards.register_award