-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstorage.lua
More file actions
183 lines (162 loc) · 5.12 KB
/
storage.lua
File metadata and controls
183 lines (162 loc) · 5.12 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
-- Carl Frank Otto III
-- carlotto81@gmail.com
-- GitHub: https://github.com/M45-Science/SoftMod
-- License: MPL 2.0
local function ensure_global_tables()
if not storage.PData then
storage.PData = {}
end
if not storage.SM_Store then
storage.SM_Store = {}
end
if not storage.SM_Store.resetDuration then
storage.SM_Store.resetDuration = ""
end
if not storage.SM_Store.purge_tasks then
storage.SM_Store.purge_tasks = {}
end
if not storage.SM_Store.restrictNew then
storage.SM_Store.restrictNew = false
end
if not storage.SM_Store.patreonCredits then
storage.SM_Store.patreonCredits = {}
end
if not storage.SM_Store.nitroCredits then
storage.SM_Store.nitroCredits = {}
end
if not storage.SM_Store.votes then
storage.SM_Store.votes = {}
end
if not storage.SM_Store.sendToSurface then
storage.SM_Store.sendToSurface = {}
end
if not storage.SM_Store.noBlueprints then
storage.SM_Store.noBlueprints = false
end
if not storage.SM_Store.oneLifeMode then
storage.SM_Store.oneLifeMode = false
end
if not storage.SM_Store.cheats then
storage.SM_Store.cheats = false
end
if not storage.SM_Store.onlineCache then
storage.SM_Store.onlineCache = ""
end
if not storage.SM_Store.pcount then
storage.SM_Store.pcount = 0
end
if not storage.SM_Store.tcount then
storage.SM_Store.tcount = 0
end
if not storage.SM_Store.playerList then
storage.SM_Store.playerList = {}
end
if storage.SM_Store.online_dirty == nil then
storage.SM_Store.online_dirty = true
end
if not storage.SM_Store.redrawLogo then
storage.SM_Store.redrawLogo = true
end
if not storage.SM_Store.serverName then
storage.SM_Store.serverName = ""
end
if not storage.SM_Store.tickDiv then
storage.SM_Store.tickDiv = 0
end
if storage.SM_Store.perms_static_applied == nil then
storage.SM_Store.perms_static_applied = false
end
end
function STORAGE_EnsureGlobal()
ensure_global_tables()
end
function STORAGE_EnsureAllPlayers()
local player_indices = {}
for player_index, _ in pairs(game.players) do
table.insert(player_indices, player_index)
end
table.sort(player_indices)
for _, player_index in ipairs(player_indices) do
local victim = game.players[player_index]
STORAGE_MakePlayerStorage(victim)
end
end
-- Create storage, if needed
function STORAGE_CreateGlobal()
STORAGE_EnsureGlobal()
STORAGE_EnsureAllPlayers()
end
-- Create player storage, if needed
function STORAGE_MakePlayerStorage(player)
if not storage.PData then
storage.PData = {}
end
if not storage.PData[player.index] then
storage.PData[player.index] = {}
end
--score
if not storage.PData[player.index].active then
storage.PData[player.index].active = false
end
if not storage.PData[player.index].moving then
storage.PData[player.index].moving = false
end
if not storage.PData[player.index].score then
storage.PData[player.index].score = 0
end
if not storage.PData[player.index].lastOnline then
storage.PData[player.index].lastOnline = game.tick
end
--prefs
if not storage.PData[player.index].hideClock then
storage.PData[player.index].hideClock = false
end
--state
if not storage.PData[player.index].cleaned then
storage.PData[player.index].cleaned = false
end
if not storage.PData[player.index].patreon then
storage.PData[player.index].patreon = false
end
if not storage.PData[player.index].nitro then
storage.PData[player.index].nitro = false
end
--throttle
if not storage.PData[player.index].regAttempts then
storage.PData[player.index].regAttempts = 0
end
if not storage.PData[player.index].lastWarned then
storage.PData[player.index].lastWarned = 0
end
if not storage.PData[player.index].reports then
storage.PData[player.index].reports = 0
end
if not storage.PData[player.index].permDeath then
storage.PData[player.index].permDeath = 0
end
--online menu
if not storage.PData[player.index].onlineBrief then
storage.PData[player.index].onlineBrief = false
end
if not storage.PData[player.index].onlineShowOffline then
storage.PData[player.index].onlineShowOffline = false
end
if not storage.PData[player.index].level then
storage.PData[player.index].level = 0
end
--promotion throttle
if not storage.PData[player.index].nextPromoTick then
storage.PData[player.index].nextPromoTick = 0
end
if not storage.PData[player.index].lastPromoScore then
storage.PData[player.index].lastPromoScore = 0
end
--ui state
if not storage.PData[player.index].info_tab_index then
storage.PData[player.index].info_tab_index = 1
end
--admin tools
if storage.PData[player.index].force_delete_armed == nil then
storage.PData[player.index].force_delete_armed = false
end
end