summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-08-04 01:32:06 +0200
committerWuzzy <almikes@aol.com>2016-08-04 01:32:06 +0200
commit10e4e9157b8951dc94614fcd369661efd2005bab (patch)
treec83537c6b477dcb6c3386a147e6ec303d58cf518 /init.lua
parent355cafd3ebb1a71833290424b1afc4d6f1da8a30 (diff)
Fix crash in empty categories
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 7835757..69bd908 100644
--- a/init.lua
+++ b/init.lua
@@ -49,7 +49,7 @@ function doc.mark_entry_as_viewed(playername, category_id, entry_id)
doc.data.players[playername].stored_data.viewed[category_id] = {}
doc.data.players[playername].stored_data.viewed_count[category_id] = 0
end
- if doc.data.players[playername].stored_data.viewed[category_id][entry_id] ~= true then
+ if doc.entry_exists(category_id, entry_id) and doc.data.players[playername].stored_data.viewed[category_id][entry_id] ~= true then
doc.data.players[playername].stored_data.viewed[category_id][entry_id] = true
doc.data.players[playername].stored_data.viewed_count[category_id] = doc.data.players[playername].stored_data.viewed_count[category_id] + 1
-- Needed because viewed entries get a different color
@@ -258,6 +258,8 @@ function doc.formspec_category(id, playername)
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)).."]"
end
return formstring
end