diff options
author | Wuzzy <almikes@aol.com> | 2016-07-24 14:30:05 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-07-24 14:30:05 +0200 |
commit | 65bc588cd7b06fd08688afde59c6387ce770e681 (patch) | |
tree | 63e4d0f4ea0d0743879778c99796a6c204649a54 | |
parent | d2b2e01710c95cab93fb886bc8f2d42caa76b1c0 (diff) |
Add func's for displaying category/entry directly
-rw-r--r-- | init.lua | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -11,6 +11,9 @@ doc.data = {} doc.data.categories = {} doc.data.players = {} +--[[ Core API functions ]] + +-- Add a new category function doc.new_category(id, def) if doc.data.categories[id] == nil and id ~= nil then doc.data.categories[id] = {} @@ -22,6 +25,7 @@ function doc.new_category(id, def) end end +-- Add a new entry function doc.new_entry(category_id, entry_id, def) if doc.data.categories[category_id] ~= nil then doc.data.categories[category_id].entries[entry_id] = def @@ -31,11 +35,33 @@ function doc.new_entry(category_id, entry_id, def) end end +-- Opens the main documentation formspec for the player function doc.show_doc(playername) local formspec = doc.formspec_core()..doc.formspec_main() minetest.show_formspec(playername, "doc:main", formspec) end +-- Opens the documentation formspec for the player at the specified category +function doc.show_category(playername, category_id) + doc.data.players[playername].catsel = nil + doc.data.players[playername].category = category_id + doc.data.players[playername].entry = nil + local formspec = doc.formspec_core(2)..doc.formspec_category(category_id, playername) + minetest.show_formspec(playername, "doc:category", formspec) +end + +-- Opens the documentation formspec for the player showing the specified entry in a category +function doc.show_entry(playername, category_id, entry_id) + doc.data.players[playername].catsel = nil + doc.data.players[playername].category = category_id + doc.data.players[playername].entry = entry_id + local eids, catsel = doc.data.players[playername].entry_ids, doc.data.players[playername].catsel + local formspec = doc.formspec_core(3)..doc.formspec_entry(category_id, entry_id) + minetest.show_formspec(playername, "doc:entry", formspec) +end + +--[[ Functions for internal use ]] + function doc.formspec_core(tab) if tab == nil then tab = 1 else tab = tostring(tab) end return "size[12,9]tabheader[0,0;doc_header;Main,Category,Entry;"..tab..";true;false]" |