From 85f3d05cefcce83f988148f06b7adfeea1b16ae3 Mon Sep 17 00:00:00 2001 From: Austin Shenk Date: Tue, 5 Feb 2013 12:00:27 -0500 Subject: [PATCH] Added quest persistence Tests if quest is already apart of the table otherwise it adds itself to the table. Quest progress is now saved on Quest Accept and Turn in as well as on a global step timer. --- standardQuest.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/standardQuest.lua b/standardQuest.lua index e355397..6c2e468 100644 --- a/standardQuest.lua +++ b/standardQuest.lua @@ -56,6 +56,7 @@ end function adventures.storeQuestData(data) local pos = {x=data[2],y=data[3],z=data[4]} local meta = minetest.env:get_meta(pos) + if adventures.quests[meta:get_string("name")] ~= nil then return end local objs = convertObjectiveString(meta:get_string("objective"), meta:get_string("description")) adventures.quests[meta:get_string("name")] = {source=pos, objectives = objs, accepted=false, completed=false, turnedIn=false, active=false} meta:set_string("formspec", adventures.updateQuestFormspec(meta, objs)) @@ -86,6 +87,7 @@ minetest.register_node("adventures:quest", { table.insert(adventures.currentObjectives["Kill"], {quest=meta:get_string("name"), index=i}) end end + adventures.saveQuestProgress() elseif fields.redeem then adventures.quests[meta:get_string("name")].turnedIn = true for _,player in pairs(minetest.get_connected_players()) do @@ -93,6 +95,7 @@ minetest.register_node("adventures:quest", { player:get_inventory():add_item("main", stack) end end + adventures.saveQuestProgress() end meta:set_string("formspec", adventures.updateQuestFormspec(meta, objs)) end,