summaryrefslogtreecommitdiff
path: root/lib/core/init.lua
blob: 9d0c01a3547bce411d89f1da52c51ff896b21b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--
-- This file is loaded at the initialisation of ToME
-- Load the system functions
--

-- Name of globals to save
tome_dofile_anywhere(ANGBAND_DIR_CORE, "load.lua")

-- Very thin xml parser(49 lines ;)
tome_dofile_anywhere(ANGBAND_DIR_CORE, "xml.lua")

-- various vital helper code
tome_dofile_anywhere(ANGBAND_DIR_CORE, "util.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "player.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "objects.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "monsters.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "building.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "s_aux.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "quests.lua")
tome_dofile_anywhere(ANGBAND_DIR_CORE, "gods.lua")

-- Load the ingame contextual help
tome_dofile_anywhere(ANGBAND_DIR_CORE, "help.lua")

-- let the store specific stuff happen!
tome_dofile_anywhere(ANGBAND_DIR_CORE, "stores.lua")

--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
-------------Here we load the non vital scripts---------------
-----------------------from lib/scpt--------------------------
--------------------------------------------------------------
--------------------------------------------------------------
tome_dofile("init.lua")

-- The dofile functions for each patch
patch_dofile = {}

-- Now load patches
function load_patches()
	scansubdir(ANGBAND_DIR_PATCH)
	for i = 0, scansubdir_max - 1 do
		if (scansubdir_result[i + 1] ~= ".") and (scansubdir_result[i + 1] ~= "..") then
			local dir = path_build(ANGBAND_DIR_PATCH, scansubdir_result[i + 1])
			local file = path_build(dir, "patch.lua")
			if file_exist(file) == TRUE then
				patch_init = nil
				tome_dofile_anywhere(dir, "patch.lua", TRUE)
				unset_safe_globals()
				if patch_init == nil then
					set_safe_globals()
					quit("Patch in "..file.." did not include a patch_init() function")
				else
					set_safe_globals()

					-- create the dofile function
					patch_dofile[scansubdir_result[i + 1]] = function(f)
						tome_dofile_anywhere(%dir, f, TRUE)
					end

					local name, version = patch_init()
					if name == nil or version == nil then
						quit("Patch in "..file.." did not return valid name or version.\nIt must return name, version")
					end
					patch_version(name, version)
				end
			end
		end
	end
end
load_patches()

--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
--
-- Do not thouch after this line
--
tome_dofile_anywhere(ANGBAND_DIR_CORE, "load2.lua")