From 41697dd683221085a9894723225942239db37d84 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 8 Nov 2016 02:10:28 +0100 Subject: Explicitly support receiving entry page events --- init.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 0b22c21..ce5e98e 100644 --- a/init.lua +++ b/init.lua @@ -354,6 +354,26 @@ function doc.get_hidden_count(playername, category_id) end end +-- Returns the currently viewed entry and/or category of the player +function doc.get_selection(playername) + local playerdata = doc.data.players[playername] + if playerdata ~= nil then + local cat = playerdata.category + if cat then + local entry = playerdata.entry + if entry then + return cat, entry + else + return cat + end + else + return nil + end + else + return nil + end +end + -- Template function templates, to be used for build_formspec in doc.new_category doc.entry_builders = {} -- cgit v1.2.3