summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md2
-rw-r--r--init.lua8
2 files changed, 9 insertions, 1 deletions
diff --git a/API.md b/API.md
index 10c0324..dc630d8 100644
--- a/API.md
+++ b/API.md
@@ -49,6 +49,8 @@ data.
* `id`: Unique category identifier as a string
* `def`: Definition table, it has the following fields:
* `name`: Category name to be shown in the interface
+ * `description`: Short description (100 characters max. recommended)
+ of the category (optional), will be shown as tooltip
* `build_formspec`: The template function. Takes entry data as its
only parameter (has the data type of the entry data) and must
return a formspec which is inserted in the Entry tab.
diff --git a/init.lua b/init.lua
index dd9474b..eb8bac3 100644
--- a/init.lua
+++ b/init.lua
@@ -172,8 +172,14 @@ function doc.formspec_main()
for c=1,#doc.data.category_order do
local id = doc.data.category_order[c]
local data = doc.data.categories[id]
+ -- Category buton
local button = "button[0,"..y..";3,1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]"
- formstring = formstring .. button
+ local tooltip = ""
+ -- Optional description
+ if data.def.description ~= nil then
+ tooltip = "tooltip[doc_button_category_"..id..";"..minetest.formspec_escape(data.def.description).."]"
+ end
+ formstring = formstring .. button .. tooltip
y = y + 1
end
return formstring