From 5e6675f3184f37caeee1a71a75b0cb88f711dc1f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 24 Jul 2016 14:59:09 +0200 Subject: New function: doc.entry_exists --- init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 8f879d2..e05fdf3 100644 --- a/init.lua +++ b/init.lua @@ -60,6 +60,17 @@ function doc.show_entry(playername, category_id, entry_id) minetest.show_formspec(playername, "doc:entry", formspec) end +-- Returns true if and only if: +-- * The specified category exists +-- * This category contains the specified entry +function doc.entry_exists(category_id, entry_id) + if doc.data.categories[category_id] ~= nil then + return doc.data.categories[category_id].entries[entry_id] ~= nil + else + return false + end +end + --[[ Functions for internal use ]] function doc.formspec_core(tab) -- cgit v1.2.3