new_entry/new_category → add_entry/add_category

This commit is contained in:
Wuzzy 2016-12-28 15:42:04 +01:00
parent c57e5c0558
commit 0f15cf4e07
2 changed files with 10 additions and 10 deletions

14
API.md
View File

@ -67,7 +67,7 @@ this block as possible.
This is a list of all publicly available functions. This is a list of all publicly available functions.
### Overview ### Overview
The most important functions are `doc.new_category` and `doc.new_entry`. All other functions The most important functions are `doc.add_category` and `doc.ad_entry`. All other functions
are mostly used for utility and examination purposes. are mostly used for utility and examination purposes.
If not mentioned otherwise, the return value of all functions is `nil`. If not mentioned otherwise, the return value of all functions is `nil`.
@ -75,8 +75,8 @@ If not mentioned otherwise, the return value of all functions is `nil`.
These functions are available: These functions are available:
#### Core #### Core
* `doc.new_category`: Adds a new category * `doc.add_category`: Adds a new category
* `doc.new_entry`: Adds a new entry * `doc.add_entry`: Adds a new entry
#### Display #### Display
* `doc.show_entry`: Shows a particular entry to a player * `doc.show_entry`: Shows a particular entry to a player
@ -115,7 +115,7 @@ widget providing an image gallery.
### `doc.new_category(id, def)` ### `doc.add_category(id, def)`
Adds a new category. You have to define an unique identifier, a name Adds a new category. You have to define an unique identifier, a name
and a template function to build the entry formspec from the entry and a template function to build the entry formspec from the entry
data. data.
@ -206,7 +206,7 @@ the standard function `minetest.register_on_player_receive_fields` to register
your event handling. The `formname` parameter will be `doc:entry`. Use your event handling. The `formname` parameter will be `doc:entry`. Use
`doc.get_selection` to get the category ID and entry ID of the entry in question. `doc.get_selection` to get the category ID and entry ID of the entry in question.
### `doc.new_entry(category_id, entry_id, def)` ### `doc.add_entry(category_id, entry_id, def)`
Adds a new entry into an existing category. You have to define the category Adds a new entry into an existing category. You have to define the category
to which to insert the entry, the entry's identifier, a name and some to which to insert the entry, the entry's identifier, a name and some
data which defines the entry. Note you do not directly define here how the data which defines the entry. Note you do not directly define here how the
@ -279,7 +279,7 @@ Returns the definition of the specified category.
#### Return value #### Return value
The category's definition table as specified in the `def` argument of The category's definition table as specified in the `def` argument of
`doc.new_category`. The table fields are the same. `doc.add_category`. The table fields are the same.
### `doc.get_entry_definition(category_id, entry_id)` ### `doc.get_entry_definition(category_id, entry_id)`
Returns the definition of the specified entry. Returns the definition of the specified entry.
@ -290,7 +290,7 @@ Returns the definition of the specified entry.
#### Return value #### Return value
The entry's definition table as specified in the `def` argument of The entry's definition table as specified in the `def` argument of
`doc.new_entry`. The table fields are the same. `doc.add_entry`. The table fields are the same.
### `doc.entry_exists(category_id, entry_id)` ### `doc.entry_exists(category_id, entry_id)`
Checks whether the specified entry exists and returns `true` or `false`. Checks whether the specified entry exists and returns `true` or `false`.

View File

@ -76,7 +76,7 @@ local set_category_order_was_called = false
--[[ Core API functions ]] --[[ Core API functions ]]
-- Add a new category -- Add a new category
function doc.new_category(id, def) function doc.add_category(id, def)
if doc.data.categories[id] == nil and id ~= nil then if doc.data.categories[id] == nil and id ~= nil then
doc.data.categories[id] = {} doc.data.categories[id] = {}
doc.data.categories[id].entries = {} doc.data.categories[id].entries = {}
@ -106,7 +106,7 @@ function doc.new_category(id, def)
end end
-- Add a new entry -- Add a new entry
function doc.new_entry(category_id, entry_id, def) function doc.add_entry(category_id, entry_id, def)
local cat = doc.data.categories[category_id] local cat = doc.data.categories[category_id]
if cat ~= nil then if cat ~= nil then
local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default) local hidden = def.hidden or (def.hidden == nil and cat.def.hide_entries_by_default)
@ -434,7 +434,7 @@ function doc.get_selection(playername)
end end
end end
-- Template function templates, to be used for build_formspec in doc.new_category -- Template function templates, to be used for build_formspec in doc.add_category
doc.entry_builders = {} doc.entry_builders = {}
-- Inserts line breaks into a single paragraph and collapses all whitespace (including newlines) -- Inserts line breaks into a single paragraph and collapses all whitespace (including newlines)