From 37ff2dd620d68e5392949da150b2641f5801efc6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 4 Aug 2016 02:21:15 +0200 Subject: Special formspec for empty categories --- init.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index b1ca24c..aafad48 100644 --- a/init.lua +++ b/init.lua @@ -282,11 +282,15 @@ function doc.formspec_category(id, playername) formstring = formstring .. "button[0,1;3,1;doc_button_goto_main;Go to category list]" else formstring = "label[0,0;Help > "..doc.data.categories[id].def.name.."]" - formstring = formstring .. "label[0,0.5;This category has the following entries:]" - formstring = formstring .. doc.generate_entry_list(id, playername) - formstring = formstring .. "button[0,8;3,1;doc_button_goto_entry;Show entry]" - formstring = formstring .. "label[8,8;Number of entries: "..doc.get_entry_count(id).."\n" - formstring = formstring .. "New entries: "..(doc.get_entry_count(id)-doc.get_viewed_count(playername, id)).."]" + if doc.get_entry_count(id) >= 1 then + formstring = formstring .. "label[0,0.5;This category has the following entries:]" + formstring = formstring .. doc.generate_entry_list(id, playername) + formstring = formstring .. "button[0,8;3,1;doc_button_goto_entry;Show entry]" + formstring = formstring .. "label[8,8;Number of entries: "..doc.get_entry_count(id).."\n" + formstring = formstring .. "New entries: "..(doc.get_entry_count(id)-doc.get_viewed_count(playername, id)).."]" + else + formstring = formstring .. "label[0,0.5;This category is empty.]" + end end return formstring end -- cgit v1.2.3