summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-02 22:10:00 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:25 +0200
commita5a4f737005258097fb46a7c746ac202575fd03e (patch)
treef10f14909a953c5fbbeb4730244525a7844092d8 /lib
parent13543856597dc59f3cf8b7ecbf7d2e77e07c7f69 (diff)
Lua: Move module initialization code to C
Diffstat (limited to 'lib')
-rw-r--r--lib/mods/mods_aux.lua185
-rw-r--r--lib/mods/modules.lua5
-rw-r--r--lib/mods/theme/module.lua48
-rw-r--r--lib/module.lua36
4 files changed, 0 insertions, 274 deletions
diff --git a/lib/mods/mods_aux.lua b/lib/mods/mods_aux.lua
deleted file mode 100644
index 1562a566..00000000
--- a/lib/mods/mods_aux.lua
+++ /dev/null
@@ -1,185 +0,0 @@
--- Ok some functions that we dont need are dangerous
---[[
-execute = nil
-getenv = nil
-setlocale = nil
-exit = nil
-openfile = nil
-writeto = nil
-readfrom = nil
-appendto = nil
-remove = nil
-rename = nil
-tmpname = nil
-]]
-modules = {}
-
-current_module = nil
-
-function setup_module(mod)
- -- For standart game, nothing needs to be done
- if not mod.layout then return end
-
- for k, e in mod.layout do
- module_reset_dir(k, e)
- end
-end
-
-function init_module(i)
- setup_module(get_module(i))
-end
-
-function max_modules()
- local i = 0
- for k, e in modules do
- if type(k) == "number" and type(e) == "table" then
- i = i + 1
- end
- end
- return i
-end
-
-function get_module_name(j)
- local i = 0
- for k, e in modules do
- if type(k) == "number" and type(e) == "table" then
- if i == j then return e.name end
- i = i + 1
- end
- end
-end
-
-function get_module_desc(j)
- local i = 0
- for k, e in modules do
- if type(k) == "number" and type(e) == "table" then
- if i == j then return e.desc end
- i = i + 1
- end
- end
-end
-
-function get_module(j)
- local i = 0
- for k, e in modules do
- if type(k) == "number" and type(e) == "table" then
- if i == j then return e end
- i = i + 1
- end
- end
-end
-
-function find_module(name)
- local i = 0
- for k, e in modules do
- if type(k) == "number" and type(e) == "table" then
- if name == e.name then return i end
- i = i + 1
- end
- end
-end
-
-function assign_current_module(name)
- current_module = get_module(find_module(name))
-end
-
-function get_module_info(type, subtype)
- if subtype then
- return current_module[type][subtype]
- else
- return current_module[type]
- end
-end
-
-function exec_module_info(type, ...)
- return call(current_module[type], arg)
-end
-
-function module_savefile_loadable(savefile_mod, savefile_death)
- for _, e in current_module.mod_savefiles do
- if e[1] == savefile_mod then
- if e[2] == "all" then
- return TRUE
- elseif e[2] == "alive" and savefile_death == FALSE then
- return TRUE
- elseif e[2] == "dead" and savefile_death == TRUE then
- return TRUE
- end
- end
- end
- return FALSE
-end
-
-function scan_extra_modules()
- scansubdir(ANGBAND_DIR_MODULES)
- for i = 0, scansubdir_max - 1 do
- if (scansubdir_result[i + 1] ~= ".") and (scansubdir_result[i + 1] ~= "..") then
- local dir = path_build(ANGBAND_DIR_MODULES, scansubdir_result[i + 1])
- local file = path_build(dir, "module.lua")
- if file_exist(file) == TRUE then
- tome_dofile_anywhere(dir, "module.lua")
- end
- end
- end
-end
-
-function add_module(t)
- assert(t.name, "No module name")
- assert(type(t.version) == "table", "No module version")
- assert(t.desc, "No module desc")
- assert(t.author, "No module author")
- assert(t.mod_savefiles, "No loadable savefiles module mark")
-
- for _, e in modules do
- if type(e) == "table" and e.name == t.name then
- error("Module name already defined: "..t.name)
- end
- end
-
- if type(t.author) == "string" then
- t.author = { t.author, "unknown@unknown.net" }
- end
-
- for k, e in t.mod_savefiles do
- if type(e) == "string" then t.mod_savefiles[k] = { e, "all" } end
- end
-
- if type(t.desc) == "table" then
- local d = ""
- for k, e in t.desc do
- d = d .. e
- if k < getn(t.desc) then
- d = d .. "\n"
- end
- end
- t.desc = d
- end
-
- if not t.rand_quest then t.rand_quest = FALSE end
- if not t.C_quest then t.C_quest = FALSE end
-
- if not t.base_dungeon then t.base_dungeon = 4 end
- if not t.death_dungeon then t.death_dungeon = 28 end
-
- if not t.astral_dungeon then t.astral_dungeon = 8 end
- if not t.astral_wild_x then t.astral_wild_x = 45 end
- if not t.astral_wild_y then t.astral_wild_y = 19 end
-
- if not t.random_artifact_weapon_chance then
- t.random_artifact_weapon_chance = 30
- end
- if not t.random_artifact_armor_chance then
- t.random_artifact_armor_chance = 20
- end
- if not t.random_artifact_jewelry_chance then
- t.random_artifact_jewelry_chance = 20
- end
-
- if not t.max_plev then t.max_plev = 50 end
- if not t.max_skill_overage then t.max_skill_overage = 4 end
- if not t.skill_per_level then t.skill_per_level = function() return 6 end end
-
- if not t.allow_birth then t.allow_birth = TRUE end
-
- tinsert(modules, t)
-end
diff --git a/lib/mods/modules.lua b/lib/mods/modules.lua
deleted file mode 100644
index 5deddef7..00000000
--- a/lib/mods/modules.lua
+++ /dev/null
@@ -1,5 +0,0 @@
--- Load ToME
-tome_dofile_anywhere(ANGBAND_DIR, "module.lua")
-
--- Look for more modules
-scan_extra_modules()
diff --git a/lib/mods/theme/module.lua b/lib/mods/theme/module.lua
deleted file mode 100644
index cc0b6f08..00000000
--- a/lib/mods/theme/module.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-add_module
-{
- ["name"] = "Theme",
- ["version"] = { 1, 2, 0 },
- ["author"] = { "furiosity", "furiosity@gmail.com" },
- ["desc"] = {
- "A module that goes back to Tolkien roots, though by no means canonical.",
- "A new wilderness map, new monsters, objects, artifacts, uniques, ego items,",
- "terrain features, gods, races, subraces, and classes. Have fun. :-)",
- },
-
- ["rand_quest"] = TRUE,
- ["C_quest"] = TRUE,
-
- ["base_dungeon"] = 4,
- ["death_dungeon"] = 28,
-
- ["astral_dungeon"] = 8,
- ["astral_wild_x"] = 45,
- ["astral_wild_y"] = 19,
-
- ["random_artifact_weapon_chance"] = 30,
- ["random_artifact_armor_chance"] = 30,
- ["random_artifact_jewelry_chance"] = 30,
-
- ["max_plev"] = 50,
- ["max_skill_overage"] = 5,
-
- ["mod_savefiles"]=
- {
- "Theme",
- },
- ["layout"] =
- {
- ["apex"] = "theme",
- ["core"] = "theme",
- ["data"] = "theme",
- ["dngn"] = "theme",
- ["edit"] = "theme",
- ["file"] = "theme",
- ["help"] = "theme",
- ["note"] = "theme",
- ["save"] = "theme",
- ["scpt"] = "theme",
- ["user"] = "theme",
- ["pref"] = "theme",
- },
-} \ No newline at end of file
diff --git a/lib/module.lua b/lib/module.lua
deleted file mode 100644
index edbaa34b..00000000
--- a/lib/module.lua
+++ /dev/null
@@ -1,36 +0,0 @@
-add_module
-{
- ["name"] = "ToME",
- ["version"] = { 2, 3, 9 },
- ["author"] = { "DarkGod", "darkgod@t-o-m-e.net" },
- ["desc"] = {
- "The Tales of Middle-earth, the standard and official game.",
- "You are set on a quest to investigate the old tower of Dol Guldur.",
- "But who knows what will happen...",
- },
-
- ["rand_quest"] = TRUE,
- ["C_quest"] = TRUE,
-
- ["base_dungeon"] = 4,
- ["death_dungeon"] = 28,
-
- ["astral_dungeon"] = 8,
- ["astral_wild_x"] = 45,
- ["astral_wild_y"] = 19,
-
- ["random_artifact_weapon_chance"] = 30,
- ["random_artifact_armor_chance"] = 20,
- ["random_artifact_jewelry_chance"] = 20,
-
- ["max_plev"] = 50,
- ["max_skill_overage"] = 4,
- ["skill_per_level"] = function()
- return 6
- end,
-
- ["mod_savefiles"]=
- {
- "ToME",
- },
-}