2018-04-04 23:57:27 +02:00
|
|
|
-- Copyright (c) 2013-18 rubenwardy. MIT.
|
2015-06-10 19:48:20 +02:00
|
|
|
|
2023-05-19 17:30:49 +02:00
|
|
|
-- Internationalization support.
|
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
|
|
|
|
2017-02-21 08:45:45 +01:00
|
|
|
-- The global award namespace
|
|
|
|
awards = {
|
2018-04-04 18:01:55 +02:00
|
|
|
show_mode = "hud",
|
2021-01-10 17:24:45 +01:00
|
|
|
registered_awards = {},
|
2018-04-04 18:01:55 +02:00
|
|
|
registered_triggers = {},
|
2021-01-10 17:24:45 +01:00
|
|
|
on_unlock = {},
|
2023-05-19 17:30:49 +02:00
|
|
|
translator = S,
|
2017-02-21 08:45:45 +01:00
|
|
|
}
|
2013-02-22 18:53:42 +01:00
|
|
|
|
2018-04-04 18:42:12 +02:00
|
|
|
-- Load files
|
2023-05-19 17:30:49 +02:00
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname()).."/src"
|
|
|
|
dofile(modpath.."/data.lua")
|
|
|
|
dofile(modpath.."/api_awards.lua")
|
|
|
|
dofile(modpath.."/api_triggers.lua")
|
|
|
|
dofile(modpath.."/chat_commands.lua")
|
|
|
|
dofile(modpath.."/gui.lua")
|
|
|
|
dofile(modpath.."/triggers.lua")
|
2020-04-04 19:46:41 +02:00
|
|
|
|
|
|
|
-- Optionally add default awards.
|
|
|
|
if minetest.settings:get_bool("awards.add_defaults", true) then
|
2023-05-19 17:30:49 +02:00
|
|
|
dofile(modpath.."/awards.lua")
|
2020-04-04 19:46:41 +02:00
|
|
|
end
|
2018-09-13 18:31:58 +02:00
|
|
|
|
|
|
|
awards.load()
|
|
|
|
minetest.register_on_shutdown(awards.save)
|
|
|
|
|
2023-05-19 17:41:01 +02:00
|
|
|
local function check_save()
|
|
|
|
awards.save()
|
|
|
|
minetest.after(18, check_save)
|
|
|
|
end
|
|
|
|
minetest.after(8 * math.random() + 10, check_save)
|
|
|
|
|
2018-04-04 18:01:55 +02:00
|
|
|
|
2018-04-04 18:37:43 +02:00
|
|
|
-- Backwards compatibility
|
2018-04-05 18:09:42 +02:00
|
|
|
awards.give_achievement = awards.unlock
|
|
|
|
awards.getFormspec = awards.get_formspec
|
|
|
|
awards.showto = awards.show_to
|
|
|
|
awards.register_onDig = awards.register_on_dig
|
|
|
|
awards.register_onPlace = awards.register_on_place
|
|
|
|
awards.register_onDeath = awards.register_on_death
|
|
|
|
awards.register_onChat = awards.register_on_chat
|
|
|
|
awards.register_onJoin = awards.register_on_join
|
|
|
|
awards.register_onCraft = awards.register_on_craft
|
|
|
|
awards.def = awards.registered_awards
|
|
|
|
awards.register_achievement = awards.register_award
|