-
Notifications
You must be signed in to change notification settings - Fork 8
/
gui-state.lua
33 lines (30 loc) · 955 Bytes
/
gui-state.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
local function assert_state_exists(player_index)
if storage.tycoon_gui_state == nil then
storage.tycoon_gui_state = {}
end
if storage.tycoon_gui_state[player_index] == nil then
storage.tycoon_gui_state[player_index] = {}
end
end
local function set_state(player_index, key, path)
assert(player_index, "Player index must not be nil.")
assert(key, "Key must not be nil.")
assert_state_exists(player_index)
storage.tycoon_gui_state[player_index][key] = path
end
local function get_state(player_index, key)
assert(player_index, "Player index must not be nil.")
assert(key, "Key must not be nil.")
assert_state_exists(player_index)
return storage.tycoon_gui_state[player_index][key]
end
return {
set_state = set_state,
get_state = get_state,
housing_type_to_tab = {
["overview"] = 1,
["simple"] = 2,
["residential"] = 3,
["highrise"] = 4,
},
}