Very simple hidden entries
This commit is contained in:
parent
5e813bffa1
commit
a2cbdbf525
2
API.md
2
API.md
@ -110,6 +110,8 @@ the category definition.
|
|||||||
* `entry_id`: Unique identifier of the new entry, as a string
|
* `entry_id`: Unique identifier of the new entry, as a string
|
||||||
* `def`: Definition table, it has the following fields:
|
* `def`: Definition table, it has the following fields:
|
||||||
* `name`: Entry name to be shown in the interface
|
* `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;
|
* `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
|
The data in this field will be used to create the actual formspec
|
||||||
with `build_formspec` from the category definition
|
with `build_formspec` from the category definition
|
||||||
|
22
init.lua
22
init.lua
@ -224,17 +224,19 @@ function doc.generate_entry_list(cid, playername)
|
|||||||
doc.data.players[playername].entry_ids = {}
|
doc.data.players[playername].entry_ids = {}
|
||||||
local entries = doc.get_sorted_entry_names(cid)
|
local entries = doc.get_sorted_entry_names(cid)
|
||||||
for i=1, #entries do
|
for i=1, #entries do
|
||||||
local eid = entries[i].eid
|
if not entries[i].hidden then
|
||||||
table.insert(doc.data.players[playername].entry_ids, eid)
|
local eid = entries[i].eid
|
||||||
-- Colorize entries based on viewed status
|
table.insert(doc.data.players[playername].entry_ids, eid)
|
||||||
-- Not viewed: Cyan
|
-- Colorize entries based on viewed status
|
||||||
local viewedprefix = "#00FFFF"
|
-- Not viewed: Cyan
|
||||||
if doc.entry_viewed(playername, cid, eid) then
|
local viewedprefix = "#00FFFF"
|
||||||
-- Viewed: White
|
if doc.entry_viewed(playername, cid, eid) then
|
||||||
viewedprefix = "#FFFFFF"
|
-- Viewed: White
|
||||||
|
viewedprefix = "#FFFFFF"
|
||||||
|
end
|
||||||
|
entry_textlist = entry_textlist .. viewedprefix .. minetest.formspec_escape(entries[i].name) .. ","
|
||||||
|
counter = counter + 1
|
||||||
end
|
end
|
||||||
entry_textlist = entry_textlist .. viewedprefix .. minetest.formspec_escape(entries[i].name) .. ","
|
|
||||||
counter = counter + 1
|
|
||||||
end
|
end
|
||||||
if counter >= 1 then
|
if counter >= 1 then
|
||||||
entry_textlist = string.sub(entry_textlist, 1, #entry_textlist-1)
|
entry_textlist = string.sub(entry_textlist, 1, #entry_textlist-1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user