1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-02-24 06:50:26 +01:00

[mff_quests] Add levermaniac quest and fix a crash

This commit is contained in:
Wouters Dorian 2015-10-17 12:48:01 +02:00
parent 7fe640d285
commit 3e177a3fc9

View File

@ -53,6 +53,16 @@ mff.quests.quests = {
}
}
}
},
levermaniac = {
title = "Levermaniac",
description = "For some reason you've become obsessed with Mesecons's lever, causing you to insanely switch the levers on and off at an amazing speed.\nDoctors have diagnosed a strange brain damage, but said you'd be rewarded with a Super Apple if you can assist them in their research about the disease.\nThey simply ask you to flip a lever 5 times, but won't come to inspect and study you afterwards, which may suggest they also are brain damaged.",
repeating = 60*60*24,
max = 5,
awards = {["maptools:superapple"] = 1},
objective = {
punch = {"mesecons_walllever:wall_lever"}
}
}
}
@ -81,7 +91,10 @@ end
-- Register the quests defined above
for qname, quest in pairs(mff.quests.quests) do
quest.completecallback = mff.quests.handle_quest_end
local ret = quests.register_quest(mff.QPREFIX .. qname, quest)
local ret, err = quests.register_quest(mff.QPREFIX .. qname, quest)
if not ret then
minetest.log("error", "mff_quests: failed registering " .. qname .. ": " .. err)
end
end
-- The callback function parameters are as follows:
@ -94,19 +107,21 @@ local function iterate_through_objectives(pname, callback)
for qname, quest in pairs(mff.quests.quests) do
if quest.tasks then
for tname, task in pairs(quest.tasks) do
if not quests.is_task_disabled(pname, mff.QPREFIX .. qname, tname) then
if quests.is_task_disabled(pname, mff.QPREFIX .. qname, tname) == false then
callback(qname, quest, tname, task, task, task.objective, function (value)
quests.update_quest_task(pname, mff.QPREFIX .. qname, tname, value)
end)
end
end
else
if quests.get_quest_progress(pname, mff.QPREFIX .. qname) ~= nil then
callback(qname, quest, nil, nil, quest, quest.objective, function (value)
quests.update_quest(pname, mff.QPREFIX .. qname, value)
end)
end
end
end
end
local function contains_node_or_group(table, element)
for _, value in pairs(table) do
@ -154,7 +169,7 @@ end)
minetest.register_on_joinplayer(function (player)
local playername = player:get_player_name()
for _, qname in ipairs({"still_testing_quests", "still_testing_quests2", "still_testing_quests3"}) do
for _, qname in ipairs({"still_testing_quests", "still_testing_quests2", "still_testing_quests3", "levermaniac"}) do
if not quests.quest_restarting_in(playername, mff.QPREFIX .. qname) then
mff.quests.start_quest(playername, qname)
end