From fd2582ed88ffae53954ee6ed525ac2fc5d63b8e4 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Fri, 24 Jul 2015 11:02:35 +0200 Subject: [PATCH] Fix various quest issues - Fix global variable 'quests' (quests/init.lua) - Fix minetest.register_on_dignode's function to handle the rare case where 'digger' == nil (mff/mff_quests/init.lua) - Made the only available quests (yet) more explicit (mff/mff_quests/init.lua) --- mods/mff/mff_quests/init.lua | 7 ++++--- mods/quests/init.lua | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/mff/mff_quests/init.lua b/mods/mff/mff_quests/init.lua index 634df943..9fe2b92c 100755 --- a/mods/mff/mff_quests/init.lua +++ b/mods/mff/mff_quests/init.lua @@ -17,9 +17,9 @@ mff.QPREFIX = "mff_quests:" mff.quests.quests = { testdiggydiggyhole = { - title = "Dig 10 nodes", + title = "Dig 10 stone nodes", max = 10, - desc = "As long as you can not dig, you are not a real miner.", + desc = "As long as you can not dig stone, you are not a real miner.", periodicity = 10, objective = { dig = {"default:stone"} @@ -84,6 +84,7 @@ end -- For quests where you have to dig something, the updates happen here minetest.register_on_dignode(function(pos, oldnode, digger) + if not digger then return end -- Already happened before local qstatus = mff.quests.quest_status[digger:get_player_name()] for qname, quest in pairs(mff.quests.quests) do if qstatus[qname] ~= nil and qstatus[qname] >= 0 then @@ -116,4 +117,4 @@ end) minetest.register_on_shutdown(function() -- TODO save data -end) \ No newline at end of file +end) diff --git a/mods/quests/init.lua b/mods/quests/init.lua index ba2313d5..a37a8baf 100755 --- a/mods/quests/init.lua +++ b/mods/quests/init.lua @@ -1,5 +1,6 @@ -- reading previous quests local file = io.open(minetest.get_worldpath().."/quests", "r") +quests = {} if file then minetest.log("action", "Reading quests...") quests = minetest.deserialize(file:read("*all"))