summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-08-01 05:36:50 +0200
committerWuzzy <almikes@aol.com>2016-08-01 05:36:50 +0200
commitdb3ecde0882c6cde9f24b41aba1fb42af8a1408c (patch)
treef1f2b9ec09a26fcaeecf055b706c5ca8c02bad63 /init.lua
parent73bf1e08bb86843a20fd339e7c39ad716e854cc2 (diff)
Sort categories (first come, first serve)
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 8fcecd8..8b29c95 100644
--- a/init.lua
+++ b/init.lua
@@ -9,6 +9,7 @@ doc.VERSION.STRING = doc.VERSION.MAJOR.."."..doc.VERSION.MINOR.."."..doc.VERSION
doc.data = {}
doc.data.categories = {}
+doc.data.category_order = {}
doc.data.players = {}
-- Space for additional APIs
@@ -23,6 +24,7 @@ function doc.new_category(id, def)
doc.data.categories[id].entries = {}
doc.data.categories[id].def = def
doc.data.categories[id].entry_aliases = {}
+ table.insert(doc.data.category_order, id)
return true
else
return false
@@ -125,7 +127,9 @@ end
function doc.formspec_main()
local y = 1
local formstring = "label[0,0;Available help topics:]"
- for id,data in pairs(doc.data.categories) do
+ for c=1,#doc.data.category_order do
+ local id = doc.data.category_order[c]
+ local data = doc.data.categories[id]
local button = "button[0,"..y..";3,1;doc_button_category_"..id..";"..minetest.formspec_escape(data.def.name).."]"
formstring = formstring .. button
y = y + 1