-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig-loader.lua
More file actions
39 lines (30 loc) · 916 Bytes
/
config-loader.lua
File metadata and controls
39 lines (30 loc) · 916 Bytes
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
local Config = {}
local cache = {}
--- Obtém o multiplicador de dificuldade
--- @return number
function Config.getDifficultyMultiplier()
return Config.get("difficulty-multiplier")
end
--- Obtém valor de configuração do mod
--- Procura automaticamente em startup, global ou player
--- @param name string Nome da configuração
--- @return any
function Config.get(name)
if cache[name] then
return cache[name]
end
local value
if settings.startup and settings.startup[name] then
value = settings.startup[name].value
elseif settings.global and settings.global[name] then
value = settings.global[name].value
elseif settings.player and settings.player[name] then
value = settings.player[name].value
end
if value == nil then
error("Setting não encontrado: " .. name)
end
cache[name] = value
return value
end
return Config