forked from KirillNaumkin/Teleportation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.lua
98 lines (92 loc) · 2.54 KB
/
settings.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
data:extend({
{
type = "bool-setting",
name = "Teleportation-telelogistics-enabled",
setting_type = "startup",
default_value = false,
},
{
type = "bool-setting",
name = "Teleportation-all-beacons-for-all",
setting_type = "runtime-global",
default_value = false,
},
{
type = "bool-setting",
name = "Teleportation-straight-jump-ignores-collisions",
setting_type = "runtime-per-user",
default_value = false,
per_user = true,
},
{
type = "int-setting",
name = "Teleportation-page-size",
setting_type = "runtime-per-user",
default_value = 20,
minimum_value = 5,
maximum_value = 50,
per_user = true,
},
})
--[[
Types of settings:
• startup - game must be restarted if changed (such a setting may affect prototypes' changes)
• runtime-global - per-world setting
• runtime-per-user - per-user setting
Types of values:
• bool-setting
• double-setting
• int-setting
• string-setting
Files being processed by the game:
• settings.lua
• settings-updates.lua
• settings-final-fixes.lua
Using in DATA.lua:
data:extend({
{
type = "int-setting",
name = "setting-name1",
setting_type = "runtime-per-user",
default_value = 25,
minimum_value = -20,
maximum_value = 100,
per_user = true,
},
{
type = "bool-setting",
name = "setting-name2",
setting_type = "runtime-per-user",
default_value = true,
per_user = true,
},
{
type = "double-setting",
name = "setting-name3",
setting_type = "runtime-per-user",
default_value = -23,
per_user = true,
},
{
type = "string-setting",
name = "setting-name4",
setting_type = "runtime-per-user",
default_value = "Hello",
allowed_values = {"Hello", "foo", "bar"},
per_user = true,
},
})
Using in LOCALE.cfg:
[mod-setting-name]
setting-name1=Seting name
[mod-setting-description]
setting-name1=Seting description
Using in CONTROL.lua and in other code for reading:
EVENT: on_runtime_mod_setting_changed - called when a player changed its setting
event.player_index
event.setting
GET: settings.startup["setting-name"].value - current value of startup setting; can be used in DATA.lua
GET: settings.global["setting-name"].value - current value of per-world setting
GET: set = settings.get_player_settings(LuaPlayer) - current values for per-player settings; then use set["setting-name"].value
GET: settings.player - default values
]]