API: get_category_definition, get_entry_definition
This commit is contained in:
parent
d172996451
commit
c5573d1d26
22
API.md
22
API.md
@ -148,6 +148,28 @@ of a category (Entry tab).
|
|||||||
#### Return value
|
#### Return value
|
||||||
Always `nil`.
|
Always `nil`.
|
||||||
|
|
||||||
|
### `doc.get_category_definition(category_id)`
|
||||||
|
Returns the definition of the specified category.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
* `category_id`: Category identifier of the category to the the definition
|
||||||
|
for
|
||||||
|
|
||||||
|
#### Return value
|
||||||
|
The category's definition table as spefied in the `def` argument of
|
||||||
|
`doc.new_category`. The table fields are the same.
|
||||||
|
|
||||||
|
### `doc.get_entry_definition(category_id, entry_id)`
|
||||||
|
Returns the definition of the specified entry.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
* `category_id`: Category identifier of entry's category
|
||||||
|
* `entry_id`: Entry identifier of the entry to get the definition for
|
||||||
|
|
||||||
|
#### Return value
|
||||||
|
The entry's definition table as spefied in the `def` argument of
|
||||||
|
`doc.new_entry`. The table fields are the same.
|
||||||
|
|
||||||
### `doc.entry_exists(category_id, entry_id)`
|
### `doc.entry_exists(category_id, entry_id)`
|
||||||
Checks if the specified entry exists and returns `true` or `false`.
|
Checks if the specified entry exists and returns `true` or `false`.
|
||||||
|
|
||||||
|
16
init.lua
16
init.lua
@ -66,6 +66,22 @@ function doc.entry_viewed(playername, category_id, entry_id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns category definition
|
||||||
|
function doc.get_category_definition(category_id)
|
||||||
|
if doc.data.categories[category_id] == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return doc.data.categories[category_id].def
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns entry definition
|
||||||
|
function doc.get_entry_definition(category_id, entry_id)
|
||||||
|
if not doc.entry_exists(category_id, entry_id) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return doc.data.categories[category_id].entries[entry_id]
|
||||||
|
end
|
||||||
|
|
||||||
-- Opens the main documentation formspec for the player
|
-- Opens the main documentation formspec for the player
|
||||||
function doc.show_doc(playername)
|
function doc.show_doc(playername)
|
||||||
if doc.get_category_count() <= 0 then
|
if doc.get_category_count() <= 0 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user