diff options
author | Wuzzy <almikes@aol.com> | 2016-08-04 01:32:06 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-08-04 01:32:06 +0200 |
commit | 10e4e9157b8951dc94614fcd369661efd2005bab (patch) | |
tree | c83537c6b477dcb6c3386a147e6ec303d58cf518 /init.lua | |
parent | 355cafd3ebb1a71833290424b1afc4d6f1da8a30 (diff) |
Fix crash in empty categories
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 |