1
0
mirror of https://github.com/TeTpaAka/quests.git synced 2024-12-22 16:50:39 +01:00

Don't show a list when there are no quests

This commit is contained in:
TeTpaAka 2015-03-01 09:46:44 +01:00
parent 96d7ba3c3b
commit 7a41a2a8ad

View File

@ -359,6 +359,7 @@ function quests.create_formspec(playername, tab)
end end
quests.formspec_lists[playername].tab = tab quests.formspec_lists[playername].tab = tab
local no_quests = true
for questname,questspecs in pairs(questlist) do for questname,questspecs in pairs(questlist) do
if (questspecs.finished == nil) then if (questspecs.finished == nil) then
local queststring = quests.registered_quests[questname]["title"] local queststring = quests.registered_quests[questname]["title"]
@ -369,11 +370,16 @@ function quests.create_formspec(playername, tab)
end end
table.insert(queststringlist, queststring) table.insert(queststringlist, queststring)
table.insert(quests.formspec_lists[playername].list, questname) table.insert(quests.formspec_lists[playername].list, questname)
no_quests = false
end end
end end
local formspec = "size[7,10]".. local formspec = "size[7,10]"..
"tabheader[0,0;header;Open quests,Finished quests,Failed quests;" .. tab .. "]".. "tabheader[0,0;header;Open quests,Finished quests,Failed quests;" .. tab .. "]"
"textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(queststringlist, ",") .. ";1;false]" if (no_quests) then
formspec = formspec .. "label[0.25,0.25;There are no quests in this category.]"
else
formspec = formspec .. "textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(queststringlist, ",") .. ";1;false]"
end
if (quests.formspec_lists[playername].tab == "1") then if (quests.formspec_lists[playername].tab == "1") then
formspec = formspec .."button[0.25,8;3,.7;abort;Abort quest]" formspec = formspec .."button[0.25,8;3,.7;abort;Abort quest]"
end end