mirror of
https://github.com/TeTpaAka/quests.git
synced 2024-12-22 16:50:39 +01:00
Added display of the description
This commit is contained in:
parent
eb706e91ed
commit
96a0e1a0e2
41
init.lua
41
init.lua
@ -119,10 +119,10 @@ function quests.register_quest(playername, questname, quest)
|
|||||||
end
|
end
|
||||||
quests.registered_quests[playername][questname] =
|
quests.registered_quests[playername][questname] =
|
||||||
{ value = 0,
|
{ value = 0,
|
||||||
title = quest.title,
|
title = quest.title or "missing title",
|
||||||
description = quest.description,
|
description = quest.description or "missing description",
|
||||||
max = quest.max or 1,
|
max = quest.max or 1,
|
||||||
autoaccept = quest.autoaccept,
|
autoaccept = quest.autoaccept or false,
|
||||||
callback = quest.callback, }
|
callback = quest.callback, }
|
||||||
quests.update_hud(playername)
|
quests.update_hud(playername)
|
||||||
return true
|
return true
|
||||||
@ -193,15 +193,17 @@ function quests.create_formspec(playername)
|
|||||||
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
||||||
local queststring = questspecs["title"]
|
local queststring = questspecs["title"]
|
||||||
if (questspecs["max"] ~= 1) then
|
if (questspecs["max"] ~= 1) then
|
||||||
local queststring = questring .. " - (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")"
|
local queststring = queststring .. " - (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")"
|
||||||
end
|
end
|
||||||
table.insert(questlist, queststring)
|
table.insert(questlist, queststring)
|
||||||
table.insert(quests.formspec_lists[playername].list, questname)
|
table.insert(quests.formspec_lists[playername].list, questname)
|
||||||
end
|
end
|
||||||
local formspec = "size[7,9]"..
|
local formspec = "size[7,10]"..
|
||||||
"textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(questlist, ",") .. ";1;false]" ..
|
"textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(questlist, ",") .. ";1;false]" ..
|
||||||
"button[0.25,8;3,.7;abort;Abort quest]" ..
|
"button[0.25,8;3,.7;abort;Abort quest]" ..
|
||||||
"button[3.75,8;3,.7;config;Configure]"
|
"button[3.75,8;3,.7;config;Configure]"..
|
||||||
|
"button[.25,9;3,.7;info;Info]"..
|
||||||
|
"button_exit[3.75,9;3,.7;exit;Exit]"
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -215,7 +217,17 @@ function quests.create_config(playername)
|
|||||||
formspec = formspec .. "false"
|
formspec = formspec .. "false"
|
||||||
end
|
end
|
||||||
formspec = formspec .. "]"..
|
formspec = formspec .. "]"..
|
||||||
"button[.25,1.25;3,.7;return;Return"
|
"button[.25,1.25;3,.7;return;Return]"
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
-- construct the info formspec
|
||||||
|
function quests.create_info(playername, questname)
|
||||||
|
local formspec = "size[7,6.5]" ..
|
||||||
|
"label[0.5,0.5;" .. quests.registered_quests[playername][questname].title .. "]"..
|
||||||
|
"textarea[.5,1.5;6,4.5;description;;" .. quests.registered_quests[playername][questname].description .. "]" ..
|
||||||
|
"button[.5,6;3,.7;abort;Abort quest]"..
|
||||||
|
"button[3.25,6;3,.7;return;Return]"
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -255,6 +267,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if (fields["config"]) then
|
if (fields["config"]) then
|
||||||
minetest.show_formspec(playername, "quests:config", quests.create_config(playername))
|
minetest.show_formspec(playername, "quests:config", quests.create_config(playername))
|
||||||
end
|
end
|
||||||
|
if (fields["info"]) then
|
||||||
|
minetest.show_formspec(playername, "quests:info", quests.create_info(playername, quests.formspec_lists[playername].list[quests.formspec_lists[playername].id]))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if (formname == "quests:config") then
|
if (formname == "quests:config") then
|
||||||
if (fields["enable"]) then
|
if (fields["enable"]) then
|
||||||
@ -268,6 +283,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
minetest.show_formspec(playername, "quests:questlog", quests.create_formspec(playername))
|
minetest.show_formspec(playername, "quests:questlog", quests.create_formspec(playername))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if (formname == "quests:info") then
|
||||||
|
if (fields["abort"]) then
|
||||||
|
if (quests.formspec_lists[playername].id == nil) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
quests.abort_quest(playername, quests.formspec_lists[playername]["list"][quests.formspec_lists[playername].id])
|
||||||
|
minetest.show_formspec(playername, "quests:questlog", quests.create_formspec(playername))
|
||||||
|
end
|
||||||
|
if (fields["return"]) then
|
||||||
|
minetest.show_formspec(playername, "quests:questlog", quests.create_formspec(playername))
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- write the quests to file
|
-- write the quests to file
|
||||||
|
Loading…
Reference in New Issue
Block a user