summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-11-07 16:02:01 +0100
committerWuzzy <almikes@aol.com>2016-11-07 16:02:01 +0100
commit5178181ccb5cb214dcda596a807ede4b9f22bc8f (patch)
treeb5f9015f31b08d65e876c02aa20d2bb5bedf48b5 /init.lua
parent5c2a4a0b3ff0ccd67bae25691a0a688d80e926dd (diff)
Remember category selection for long cat. list
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/init.lua b/init.lua
index e94419e..10cccc2 100644
--- a/init.lua
+++ b/init.lua
@@ -45,6 +45,7 @@ function doc.new_category(id, def)
doc.data.categories[id].def = def
doc.data.categories[id].entry_aliases = {}
table.insert(doc.data.category_order, id)
+ doc.data.categories[id].order_position = #doc.data.category_order
return true
else
return false
@@ -512,7 +513,12 @@ function doc.formspec_main(playername)
formstring = formstring .. ","
end
end
- formstring = formstring .. ";]"
+ formstring = formstring .. ";"
+ local sel = doc.data.categories[doc.data.players[playername].category]
+ if sel ~= nil then
+ formstring = formstring .. doc.data.categories[doc.data.players[playername].category].order_position
+ end
+ formstring = formstring .. "]"
formstring = formstring .. "button[0,8;3,1;doc_button_goto_category;"..F("Show category").."]"
end
end
@@ -808,10 +814,8 @@ function doc.process_form(player,formname,fields)
end
if fields["doc_button_goto_category"] then
local cid = doc.data.players[playername].category
- if cid ~= nil then
- local formspec = doc.formspec_core(2)..doc.formspec_category(cid, playername)
- minetest.show_formspec(playername, "doc:category", formspec)
- end
+ local formspec = doc.formspec_core(2)..doc.formspec_category(cid, playername)
+ minetest.show_formspec(playername, "doc:category", formspec)
end
elseif(formname == "doc:category") then
if fields["doc_button_goto_entry"] then