summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md2
-rw-r--r--init.lua22
2 files changed, 14 insertions, 10 deletions
diff --git a/API.md b/API.md
index 62abfb3..f05a0b5 100644
--- a/API.md
+++ b/API.md
@@ -110,6 +110,8 @@ the category definition.
* `entry_id`: Unique identifier of the new entry, as a string
* `def`: Definition table, it has the following fields:
* `name`: Entry name to be shown in the interface
+ * `hidden`: (optional) If `true`, entry will not be displayed in entry list
+ initially (default: `false`)
* `data`: Arbitrary data attached to the entry. Any data type is allowed;
The data in this field will be used to create the actual formspec
with `build_formspec` from the category definition
diff --git a/init.lua b/init.lua
index b75c4a4..aedac26 100644
--- a/init.lua
+++ b/init.lua
@@ -224,17 +224,19 @@ function doc.generate_entry_list(cid, playername)
doc.data.players[playername].entry_ids = {}
local entries = doc.get_sorted_entry_names(cid)
for i=1, #entries do
- local eid = entries[i].eid
- table.insert(doc.data.players[playername].entry_ids, eid)
- -- Colorize entries based on viewed status
- -- Not viewed: Cyan
- local viewedprefix = "#00FFFF"
- if doc.entry_viewed(playername, cid, eid) then
- -- Viewed: White
- viewedprefix = "#FFFFFF"
+ if not entries[i].hidden then
+ local eid = entries[i].eid
+ table.insert(doc.data.players[playername].entry_ids, eid)
+ -- Colorize entries based on viewed status
+ -- Not viewed: Cyan
+ local viewedprefix = "#00FFFF"
+ if doc.entry_viewed(playername, cid, eid) then
+ -- Viewed: White
+ viewedprefix = "#FFFFFF"
+ end
+ entry_textlist = entry_textlist .. viewedprefix .. minetest.formspec_escape(entries[i].name) .. ","
+ counter = counter + 1
end
- entry_textlist = entry_textlist .. viewedprefix .. minetest.formspec_escape(entries[i].name) .. ","
- counter = counter + 1
end
if counter >= 1 then
entry_textlist = string.sub(entry_textlist, 1, #entry_textlist-1)