forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserInit.lua
More file actions
68 lines (55 loc) · 2.18 KB
/
userInit.lua
File metadata and controls
68 lines (55 loc) · 2.18 KB
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
-- Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
--
-- This is the user-specific top-level lua initialization file. It is run at initialization time
-- to set up all lua state for the user layer.
-- Init our language from prefs. This applies to both front-end and session init; for
-- the Sim init, the engine sets __language for us.
__language = GetPreference('options_overrides.language', '')
-- Build language select options
__installedlanguages = DiskFindFiles("/loc/", '*strings_db.lua')
for index, language in __installedlanguages do
language = string.upper(string.gsub(language, ".*/(.*)/.*","%1"))
__installedlanguages[index] = {text = language, key = language}
end
-- Do global init
doscript '/lua/globalInit.lua'
-- Do we have an custom language set inside user-options ?
local selectedlanguage = import('/lua/user/prefs.lua').GetFromCurrentProfile('options').selectedlanguage
if selectedlanguage ~= nil then
__language = selectedlanguage
SetPreference('options_overrides.language', __language)
doscript '/lua/system/Localization.lua'
end
local AvgFPS = 10
WaitFrames = coroutine.yield
function WaitSeconds(n)
local start = CurrentTime()
local elapsed_frames = 0
local elapsed_time = 0
local wait_frames
repeat
wait_frames = math.ceil(math.max(1, AvgFPS*0.1, n * AvgFPS))
WaitFrames(wait_frames)
elapsed_frames = elapsed_frames + wait_frames
elapsed_time = CurrentTime() - start
until elapsed_time >= n
if elapsed_time >= 3 then
AvgFPS = math.max(10, math.min(200, math.ceil(elapsed_frames / elapsed_time)))
end
end
-- a table designed to allow communication from different user states to the front end lua state
FrontEndData = {}
-- Prefetch user side data
Prefetcher = CreatePrefetchSet()
local FileCache = {}
local oldDiskGetFileInfo = DiskGetFileInfo
function DiskGetFileInfo(file)
if FileCache[file] == nil then
FileCache[file] = oldDiskGetFileInfo(file) or false
end
return FileCache[file]
end
local oldEntityCategoryFilterOut = EntityCategoryFilterOut
function EntityCategoryFilterOut(categories, units)
return oldEntityCategoryFilterOut(categories, units or {})
end