-
-
Notifications
You must be signed in to change notification settings - Fork 208
/
init.lua
118 lines (92 loc) · 3.54 KB
/
init.lua
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
-- this is the first file executed when the application starts
-- we have to load the first modules form here
-- updater
Services = {
--updater = "http://localhost/api/updater.php", --./updater
--status = "http://localhost/login.php", --./client_entergame | ./client_topmenu
--websites = "http://localhost/?subtopic=accountmanagement", --./client_entergame "Forgot password and/or email"
}
--[[ Servers_init = {
["http://ip/login.php"] = {
["port"] = 80,
["protocol"] = 1332,
["httpLogin"] = true
},
["ip.net"] = {
["port"] = 7171,
["protocol"] = 860,
["httpLogin"] = false
},
} ]]
g_app.setName("OTClient - Redemption");
g_app.setCompactName("otclient");
g_app.setOrganizationName("otcr");
g_app.hasUpdater = function()
return (Services.updater and Services.updater ~= "" and g_modules.getModule("updater"))
end
-- setup logger
g_logger.setLogFile(g_resources.getWorkDir() .. g_app.getCompactName() .. '.log')
g_logger.info(os.date('== application started at %b %d %Y %X'))
g_logger.info("== operating system: " .. g_platform.getOSName())
-- print first terminal message
g_logger.info(g_app.getName() .. ' ' .. g_app.getVersion() .. ' rev ' .. g_app.getBuildRevision() .. ' (' ..
g_app.getBuildCommit() .. ') built on ' .. g_app.getBuildDate() .. ' for arch ' ..
g_app.getBuildArch())
-- setup lua debugger
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
require("lldebugger").start()
g_logger.debug("Started LUA debugger.")
else
g_logger.debug("LUA debugger not started (not launched with VSCode local-lua).")
end
-- add data directory to the search path
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'data', true) then
g_logger.fatal('Unable to add data directory to the search path.')
end
-- add modules directory to the search path
if not g_resources.addSearchPath(g_resources.getWorkDir() .. 'modules', true) then
g_logger.fatal('Unable to add modules directory to the search path.')
end
-- try to add mods path too
g_resources.addSearchPath(g_resources.getWorkDir() .. 'mods', true)
-- setup directory for saving configurations
g_resources.setupUserWriteDir(('%s/'):format(g_app.getCompactName()))
-- search all packages
g_resources.searchAndAddPackages('/', '.otpkg', true)
-- load settings
g_configs.loadSettings('/config.otml')
g_modules.discoverModules()
-- libraries modules 0-99
g_modules.autoLoadModules(99)
g_modules.ensureModuleLoaded('corelib')
g_modules.ensureModuleLoaded('gamelib')
g_modules.ensureModuleLoaded('modulelib')
g_modules.ensureModuleLoaded("startup")
g_modules.autoLoadModules(999)
g_modules.ensureModuleLoaded('game_shaders') -- pre load
local function loadModules()
-- client modules 100-499
g_modules.autoLoadModules(499)
g_modules.ensureModuleLoaded('client')
-- game modules 500-999
g_modules.autoLoadModules(999)
g_modules.ensureModuleLoaded('game_interface')
-- mods 1000-9999
g_modules.autoLoadModules(9999)
g_modules.ensureModuleLoaded('client_mods')
if not g_game.isEnabledBotProtection() then
g_modules.ensureModuleLoaded('game_bot')
end
local script = '/' .. g_app.getCompactName() .. 'rc.lua'
if g_resources.fileExists(script) then
dofile(script)
end
-- uncomment the line below so that modules are reloaded when modified. (Note: Use only mod dev)
-- g_modules.enableAutoReload()
end
-- run updater, must use data.zip
if g_app.hasUpdater() then
g_modules.ensureModuleLoaded("updater")
return Updater.init(loadModules)
end
loadModules()