diff options
| author | Wuzzy <almikes@aol.com> | 2016-10-07 06:15:42 +0200 | 
|---|---|---|
| committer | Wuzzy <almikes@aol.com> | 2016-10-07 06:15:42 +0200 | 
| commit | 95ad337f52c0013fe64832482e72491fa54cbebe (patch) | |
| tree | 3923bb0f88ada6f07d481204e638549e4584f233 | |
| parent | be4b437d4a704c2ef88f894a4007eedb6a88dc72 (diff) | |
doc.get_hidden_count
| -rw-r--r-- | API.md | 13 | ||||
| -rw-r--r-- | init.lua | 15 | 
2 files changed, 28 insertions, 0 deletions
| @@ -83,6 +83,7 @@ These functions are available:  * `doc.get_entry_count`: Returns the total number of entries in a category  * `doc.get_viewed_count`: Returns the number of entries a player has viewed in a category  * `doc.get_revealed_count`: Returns the number of entries a player has access to in a category +* `doc.get_hidden_count`: Returns the number of entries which are hidden from a player in a category  ### `doc.new_category(id, def)`  Adds a new category. You have to define an unique identifier, a name @@ -357,6 +358,18 @@ in this category.  Amount of entries the player has access to in the specified category. If the  player does not exist, this function returns `nil`. +### `function doc.get_hidden_count(playername, category_id)` +Returns how many entries are hidden from the player in this category. + +#### Parameters +* `playername`: Name of the player to count the hidden entries for +* `category_id`: Category identifier of the category in which to count the +  hidden entries + +#### Return value +Amount of entries hidden from the player. If the player does not exist, +this function returns `nil`. +  ## Extending this mod (naming conventions)  If you want to extend this mod with your own functionality, it is recommended @@ -258,6 +258,21 @@ function doc.get_revealed_count(playername, category_id)  	end  end +-- Returns how many entries are hidden from the player +function doc.get_hidden_count(playername, category_id) +	local playerdata = doc.data.players[playername] +	if playerdata == nil then +		return nil +	end +	local total = doc.get_entry_count(category_id) +	local rcount = playerdata.stored_data.revealed_count[category_id] +	if rcount == nil then +		return total +	else +		return total - rcount +	end +end +  -- Template function templates, to be used for build_formspec in doc.new_category  doc.entry_builders = {} | 
