mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 12:31:05 +01:00
Upgrade doc mod to v1.1.0
This commit is contained in:
parent
7fda66a5dd
commit
d80b75358d
2 changed files with 30 additions and 11 deletions
|
@ -4,7 +4,7 @@ can access help pages about various things and the modder can add those pages.
|
||||||
The mod itself does not provide any help texts, just the framework.
|
The mod itself does not provide any help texts, just the framework.
|
||||||
It is the heart of the Help modpack, on which the other Help mods depend.
|
It is the heart of the Help modpack, on which the other Help mods depend.
|
||||||
|
|
||||||
Current version: 1.0.1
|
Current version: 1.1.0
|
||||||
|
|
||||||
## For players
|
## For players
|
||||||
### Accessing the help
|
### Accessing the help
|
||||||
|
|
|
@ -190,6 +190,8 @@ function doc.mark_entry_as_revealed(playername, category_id, entry_id)
|
||||||
doc.data.players[playername].stored_data.revealed_count[category_id] = doc.data.players[playername].stored_data.revealed_count[category_id] + 1
|
doc.data.players[playername].stored_data.revealed_count[category_id] = doc.data.players[playername].stored_data.revealed_count[category_id] + 1
|
||||||
-- Needed because a new entry is added to the list of visible entries
|
-- Needed because a new entry is added to the list of visible entries
|
||||||
doc.data.players[playername].entry_textlist_needs_updating = true
|
doc.data.players[playername].entry_textlist_needs_updating = true
|
||||||
|
-- Notify player of entry revelation
|
||||||
|
if doc.data.players[playername].stored_data.notify_on_reveal == true then
|
||||||
if minetest.get_modpath("central_message") ~= nil then
|
if minetest.get_modpath("central_message") ~= nil then
|
||||||
local cat = doc.data.categories[category_id]
|
local cat = doc.data.categories[category_id]
|
||||||
cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name))
|
cmsg.push_message_player(minetest.get_player_by_name(playername), S("New help entry unlocked: @1 > @2", cat.def.name, entry.name))
|
||||||
|
@ -203,6 +205,7 @@ function doc.mark_entry_as_revealed(playername, category_id, entry_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Reveal
|
-- Reveal
|
||||||
function doc.mark_all_entries_as_revealed(playername)
|
function doc.mark_all_entries_as_revealed(playername)
|
||||||
|
@ -734,6 +737,7 @@ end
|
||||||
|
|
||||||
function doc.formspec_main(playername)
|
function doc.formspec_main(playername)
|
||||||
local formstring = "label[0,0;"..minetest.formspec_escape(DOC_INTRO) .. "\n"
|
local formstring = "label[0,0;"..minetest.formspec_escape(DOC_INTRO) .. "\n"
|
||||||
|
local notify_checkbox_x, notify_checkbox_y
|
||||||
if doc.get_category_count() >= 1 then
|
if doc.get_category_count() >= 1 then
|
||||||
formstring = formstring .. F("Please select a category you wish to learn more about:").."]"
|
formstring = formstring .. F("Please select a category you wish to learn more about:").."]"
|
||||||
if doc.get_category_count() <= (CATEGORYFIELDSIZE.WIDTH * CATEGORYFIELDSIZE.HEIGHT) then
|
if doc.get_category_count() <= (CATEGORYFIELDSIZE.WIDTH * CATEGORYFIELDSIZE.HEIGHT) then
|
||||||
|
@ -761,6 +765,8 @@ function doc.formspec_main(playername)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
notify_checkbox_x = 0
|
||||||
|
notify_checkbox_y = doc.FORMSPEC.HEIGHT-0.5
|
||||||
else
|
else
|
||||||
formstring = formstring .. "textlist[0,1;"..(doc.FORMSPEC.WIDTH-0.2)..","..(doc.FORMSPEC.HEIGHT-2)..";doc_mainlist;"
|
formstring = formstring .. "textlist[0,1;"..(doc.FORMSPEC.WIDTH-0.2)..","..(doc.FORMSPEC.HEIGHT-2)..";doc_mainlist;"
|
||||||
for c=1,#doc.data.category_order do
|
for c=1,#doc.data.category_order do
|
||||||
|
@ -778,7 +784,17 @@ function doc.formspec_main(playername)
|
||||||
end
|
end
|
||||||
formstring = formstring .. "]"
|
formstring = formstring .. "]"
|
||||||
formstring = formstring .. "button[0,"..(doc.FORMSPEC.HEIGHT-1)..";3,1;doc_button_goto_category;"..F("Show category").."]"
|
formstring = formstring .. "button[0,"..(doc.FORMSPEC.HEIGHT-1)..";3,1;doc_button_goto_category;"..F("Show category").."]"
|
||||||
|
notify_checkbox_x = 3.5
|
||||||
|
notify_checkbox_y = doc.FORMSPEC.HEIGHT-1
|
||||||
end
|
end
|
||||||
|
local text
|
||||||
|
if minetest.get_modpath("central_message") then
|
||||||
|
text = F("Notify me when new help is available")
|
||||||
|
else
|
||||||
|
text = F("Play notification sound when new help is available")
|
||||||
|
end
|
||||||
|
formstring = formstring .. "checkbox["..notify_checkbox_x..","..notify_checkbox_y..";doc_setting_notify_on_reveal;"..text..";"..
|
||||||
|
tostring(doc.data.players[playername].stored_data.notify_on_reveal == true) .. "]"
|
||||||
else
|
else
|
||||||
formstring = formstring .. "]"
|
formstring = formstring .. "]"
|
||||||
end
|
end
|
||||||
|
@ -1066,6 +1082,9 @@ function doc.process_form(player,formname,fields)
|
||||||
local formspec = doc.formspec_core(2)..doc.formspec_category(cid, playername)
|
local formspec = doc.formspec_core(2)..doc.formspec_category(cid, playername)
|
||||||
minetest.show_formspec(playername, "doc:category", formspec)
|
minetest.show_formspec(playername, "doc:category", formspec)
|
||||||
end
|
end
|
||||||
|
if fields["doc_setting_notify_on_reveal"] then
|
||||||
|
doc.data.players[playername].stored_data.notify_on_reveal = fields["doc_setting_notify_on_reveal"] == "true"
|
||||||
|
end
|
||||||
elseif(formname == "doc:category") then
|
elseif(formname == "doc:category") then
|
||||||
if fields["doc_button_goto_entry"] then
|
if fields["doc_button_goto_entry"] then
|
||||||
local cid = doc.data.players[playername].category
|
local cid = doc.data.players[playername].category
|
||||||
|
|
Loading…
Reference in a new issue