diff options
author | Manoj Srivastava <srivasta@debian.org> | 2014-05-14 23:54:09 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2014-05-14 23:54:09 -0700 |
commit | 4f8b58cc5366bfc2ea3b56fe6ff0443464d10f0f (patch) | |
tree | a0a9cad00e7916b9a97e14831fb362f21871cbef /lib/core/quests.lua |
tome (2.3.11-ah-2) unstable; urgency=low
* Modified the install paths to deploy to the FHS compliant
/usr/games/tome and /var/games/tome, as we have always done
* This is a major change, and includes theming. Some of the options have
changed. Because of this, the manual page has been removed; there is a
command line help option and in game help until the manual page is
rewritten.
# imported from the archive
Diffstat (limited to 'lib/core/quests.lua')
-rw-r--r-- | lib/core/quests.lua | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/core/quests.lua b/lib/core/quests.lua new file mode 100644 index 00000000..dfe9db51 --- /dev/null +++ b/lib/core/quests.lua @@ -0,0 +1,57 @@ +-- Quest helper files + +-- Quest structs + +__quest_hook = {} +__quest_callbacks = {} +__quest_callbacks_max = 0 +__quest_dynamic_desc = {} + +function add_quest(q) + local i, index, d, z, qq + + assert(q.global, "No quest global name") + assert(q.name, "No quest name") + assert(q.desc, "No quest desc") + assert(q.level, "No quest level") + assert(q.hooks, "No quest hooks") + + i = new_quest(q.name); + setglobal(q.global, i) + + -- Make it save & load + add_loadsave("quest("..q.global..").status", QUEST_STATUS_UNTAKEN) + + if type(q.desc) == "table" then + z = 0 + for index, d in q.desc do + quest_desc(i, z, d); + z = z + 1 + end + else + __quest_dynamic_desc[i] = q.desc + quest(i).dynamic_desc = TRUE + end + quest(i).level = q.level + if not q.silent then + quest(i).silent = FALSE + else + quest(i).silent = q.silent + end + __quest_hook[i] = q.hooks + for index, d in q.hooks do + add_hook_script(index, "__lua__quest_callback"..__quest_callbacks_max, "__lua__quest_callback"..__quest_callbacks_max) + setglobal("__lua__quest_callback"..__quest_callbacks_max, d) + __quest_callbacks_max = __quest_callbacks_max + 1 + end + if q.data then + for index, d in q.data do + -- Besure it exists + setglobal(index, d) + + -- Make it save & load + add_loadsave(index, d) + end + end + return i +end |