Skip to content
Snippets Groups Projects
Commit 72be7613 authored by dg's avatar dg
Browse files

Allow quests to be in addons data folder, referncing them like zones with an "addonname+" prefix

git-svn-id: http://svn.net-core.org/repos/t-engine4@6799 51575b47-30f0-44d4-a5cc-537603b46e54
parent 24df8ef5
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,19 @@ _M.quest_class = "engine.Quest"
--- Grants a quest to an actor from the given quest definition
function _M:grantQuest(quest, args)
local function getBaseName(name)
local base = "/data"
local _, _, addon, rname = name:find("^([^+]+)%+(.+)$")
print("===", addon, rname)
if addon and rname then
base = "/data-"..addon
name = rname
end
return base.."/quests/"..name..".lua"
end
if type(quest) == "string" then
local f, err = loadfile("/data/quests/"..quest..".lua")
local f, err = loadfile(getBaseName(quest))
if not f and err then error(err) end
local ret = args or {}
setfenv(f, setmetatable(ret, {__index=_G}))
......
......@@ -30,8 +30,19 @@ function _M:grantQuest(quest, args)
local mp = game.party:findMember{main=true}
if mp ~= self then return mp:grantQuest(quest, args) end
local function getBaseName(name)
local base = "/data"
local _, _, addon, rname = name:find("^([^+]+)%+(.+)$")
print("===", addon, rname)
if addon and rname then
base = "/data-"..addon
name = rname
end
return base.."/quests/"..name..".lua"
end
if type(quest) == "string" then
local f, err = loadfile("/data/quests/"..quest..".lua")
local f, err = loadfile(getBaseName(quest))
if not f and err then error(err) end
local ret = args or {}
setfenv(f, setmetatable(ret, {__index=_G}))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment