diff options
author | Bardur Arantsson <bardur@scientician.net> | 2010-01-08 20:28:34 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2010-01-08 23:46:06 +0100 |
commit | 6aa48afdd57d03314fdf4be6c9da911c32277c84 (patch) | |
tree | 2dc401f9aae2dc6736d2fc3811c8f8099d3eabe6 /lib/core/gods.lua |
Import tome-2.3.5.
Diffstat (limited to 'lib/core/gods.lua')
-rw-r--r-- | lib/core/gods.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/core/gods.lua b/lib/core/gods.lua new file mode 100644 index 00000000..77e0aad5 --- /dev/null +++ b/lib/core/gods.lua @@ -0,0 +1,40 @@ +-- Gods helper files + +-- Gods structs + +__gods_hook = {} +__gods_callbacks = {} +__gods_callbacks_max = 0 + +function add_god(q) + local i, index, d, z, qq + + assert(q.name, "No god name") + assert(q.desc, "No god desc") + assert(q.hooks, "No god hooks") + + i = add_new_gods(q.name); + + z = 0 + for index, d in q.desc do + desc_god(i, z, d); + z = z + 1 + end + + __gods_hook[i] = q.hooks + for index, d in q.hooks do + add_hook_script(index, "__lua__gods_callback"..__gods_callbacks_max, "__lua__gods_callback"..__gods_callbacks_max) + setglobal("__lua__gods_callback"..__gods_callbacks_max, d) + __gods_callbacks_max = __gods_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 |