From 1cd7d63b9d993b6524033ec0207a1133213d2ec3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 1 Aug 2016 16:40:26 +0200 Subject: Add achievement for reading block entries --- init.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 3294730..f96b5d9 100644 --- a/init.lua +++ b/init.lua @@ -694,3 +694,28 @@ local function gather_descs() end minetest.after(0, gather_descs) + +local awardchecktime = 0 +if minetest.get_modpath("awards") ~= nil then + -- TODO: Change the goal to unlocking/discovering all block entries of Minetest Game + -- (excluding unused blocks like default:cloud) + awards.register_achievement("doc_minetest_game_allnodes", { + title = "Block Index Completed", + description = "Read all help entries about blocks.", + }) + + -- TODO: Test this when the awards mod works again + minetest.register_globalstep(function(dtime) + -- Check awards every 30 seconds + awardchecktime = awardchecktime + dtime + if awardchecktime < 30 then return end + awardchecktime = 30 - awardchecktime + local players = minetest.get_connected_players() + for p=1,#players do + local count = doc.get_viewed_count(players[p]:get_player_name(), "nodes") + if count ~= nil and count >= doc.get_entry_count("nodes") then + awards.unlock("doc_minetest_game_allnodes") + end + end + end) +end -- cgit v1.2.3