Added description field to quests
The max value is now only shown if max is not 1.
This commit is contained in:
parent
9a56707c40
commit
eb706e91ed
36
init.lua
36
init.lua
@ -66,7 +66,10 @@ function quests.update_hud(playername)
|
|||||||
local text = "Open Quests:\n\n"
|
local text = "Open Quests:\n\n"
|
||||||
if (quests.registered_quests[playername] ~= nil) then
|
if (quests.registered_quests[playername] ~= nil) then
|
||||||
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
||||||
text = text .. questspecs["description"].."\n (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")\n"
|
text = text .. questspecs["title"] .. "\n"
|
||||||
|
if (questspecs["max"] ~= 1) then
|
||||||
|
text = text .." (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")\n"
|
||||||
|
end
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
if (counter >= show_max) then
|
if (counter >= show_max) then
|
||||||
break
|
break
|
||||||
@ -96,16 +99,18 @@ end
|
|||||||
-- playername is the name of the player, who gets the quest
|
-- playername is the name of the player, who gets the quest
|
||||||
-- questname is the name of the quest to identify it later
|
-- questname is the name of the quest to identify it later
|
||||||
-- it should follow the naming conventions: "modname:questname"
|
-- it should follow the naming conventions: "modname:questname"
|
||||||
-- description is shown to the player and should contain usefull information about the quest.
|
-- quest is a table in the following format
|
||||||
-- max is the desired maximum
|
-- {
|
||||||
-- autoaccept is true or false, wether the result of the quest should be dealt
|
-- title, -- is shown to the player and should contain usefull information about the quest.
|
||||||
-- by this mode or the registering mod
|
-- description, -- a small description of the mod.
|
||||||
-- when autoaccept is true, at the end of the quest, it gets removed and
|
-- max, -- is the desired maximum. If max is 1, no maximum is displayed. defaults to 1
|
||||||
-- callback is called
|
-- autoaccept, -- is true or false, wether the result of the quest should be dealt by this mode or the registering mod.
|
||||||
|
-- callback -- when autoaccept is true, at the end of the quest, it gets removed and callback is called.
|
||||||
|
-- }
|
||||||
--
|
--
|
||||||
-- returns true, when the quest was successfully registered
|
-- returns true, when the quest was successfully registered
|
||||||
-- returns falls, when there was already such a quest
|
-- returns falls, when there was already such a quest
|
||||||
function quests.register_quest(playername, questname, description, max, autoaccept, callback)
|
function quests.register_quest(playername, questname, quest)
|
||||||
if (quests.registered_quests[playername] == nil) then
|
if (quests.registered_quests[playername] == nil) then
|
||||||
quests.registered_quests[playername] = {}
|
quests.registered_quests[playername] = {}
|
||||||
end
|
end
|
||||||
@ -114,10 +119,11 @@ function quests.register_quest(playername, questname, description, max, autoacce
|
|||||||
end
|
end
|
||||||
quests.registered_quests[playername][questname] =
|
quests.registered_quests[playername][questname] =
|
||||||
{ value = 0,
|
{ value = 0,
|
||||||
description = description,
|
title = quest.title,
|
||||||
max = max,
|
description = quest.description,
|
||||||
autoaccept = autoaccept,
|
max = quest.max or 1,
|
||||||
callback = callback }
|
autoaccept = quest.autoaccept,
|
||||||
|
callback = quest.callback, }
|
||||||
quests.update_hud(playername)
|
quests.update_hud(playername)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -185,7 +191,11 @@ function quests.create_formspec(playername)
|
|||||||
quests.formspec_lists[playername].id = 1
|
quests.formspec_lists[playername].id = 1
|
||||||
quests.formspec_lists[playername].list = {}
|
quests.formspec_lists[playername].list = {}
|
||||||
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
||||||
table.insert(questlist, questspecs["description"] .. " - (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")")
|
local queststring = questspecs["title"]
|
||||||
|
if (questspecs["max"] ~= 1) then
|
||||||
|
local queststring = questring .. " - (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")"
|
||||||
|
end
|
||||||
|
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,9]"..
|
||||||
|
Loading…
Reference in New Issue
Block a user