You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core-concepts/packages/packages-guide.mdx
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,16 @@ GameModes can define Custom Settings in the `[custom_settings]` section to be se
153
153
154
154
The values defined can be accessed through the method <MethodReferencetype="StaticClass"class_name="Server"method_name="GetCustomSettings"show_class_name />.
155
155
156
+
Each setting is declared as `key = { ... }`, where the table describes how it should be displayed and validated in the New Game screen:
157
+
158
+
| Property | Type | Description |
159
+
| :--- | :--- | :--- |
160
+
|**`label`**|`string`| Friendly name displayed for this setting |
161
+
|**`type`**|`string`| One of the [types](#list-of-types) below |
162
+
|**`description`**|`string`| Help text displayed alongside the setting |
163
+
|**`default`**|`boolean`\|`integer`\|`floating`\|`string`| Default value, must match the setting `type`|
164
+
|**`options`**|`string[]`| Only used by the `select` type: the list of values shown in the dropdown |
165
+
156
166
#### List of Types {/* #list-of-types */}
157
167
158
168
| Type | Description |
@@ -163,6 +173,31 @@ The values defined can be accessed through the method <MethodReference type="Sta
163
173
|`select`| List of string values displayed as a Dropdown |
164
174
|`text`| Text Box |
165
175
176
+
#### Usage Example {/* #custom-settings-usage-example */}
177
+
178
+
```toml
179
+
[custom_settings]
180
+
max_props = { label = "Max Props", type = "integer", description = "maximum amount of props players can spawn", default = 1000 }
181
+
enable_pvp = { label = "Enable PVP", type = "boolean", description = "whether to enable PVP or not", default = true }
182
+
welcome_message = { label = "Welcome Message", type = "text", description = "message shown to players when they join", default = "have fun!" }
183
+
game_mode = { label = "Game Mode", type = "select", description = "which ruleset to use", default = "Classic", options = [ "Classic", "Hardcore", "Free for All" ] }
184
+
```
185
+
186
+
These are then exposed to every Package through <MethodReferencetype="StaticClass"class_name="Server"method_name="GetCustomSettings"show_class_name />, which returns a table keyed by the setting name and its raw value:
187
+
188
+
```lua
189
+
localsettings=Server.GetCustomSettings()
190
+
191
+
Console.Log(settings.max_props) -- 1000
192
+
Console.Log(settings.game_mode) -- "Classic"
193
+
```
194
+
195
+
They can also be overridden without touching `Package.toml`, either when creating a new game through the main menu, or by passing them directly on the command line, which takes precedence over both the New Game screen and `Package.toml` defaults:
Copy file name to clipboardExpand all lines: versioned_docs/version-latest/core-concepts/packages/packages-guide.mdx
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,16 @@ GameModes can define Custom Settings in the `[custom_settings]` section to be se
153
153
154
154
The values defined can be accessed through the method <MethodReferencetype="StaticClass"class_name="Server"method_name="GetCustomSettings"show_class_name />.
155
155
156
+
Each setting is declared as `key = { ... }`, where the table describes how it should be displayed and validated in the New Game screen:
157
+
158
+
| Property | Type | Description |
159
+
| :--- | :--- | :--- |
160
+
|**`label`**|`string`| Friendly name displayed for this setting |
161
+
|**`type`**|`string`| One of the [types](#list-of-types) below |
162
+
|**`description`**|`string`| Help text displayed alongside the setting |
163
+
|**`default`**|`boolean`\|`integer`\|`floating`\|`string`| Default value, must match the setting `type`|
164
+
|**`options`**|`string[]`| Only used by the `select` type: the list of values shown in the dropdown |
165
+
156
166
#### List of Types {/* #list-of-types */}
157
167
158
168
| Type | Description |
@@ -163,6 +173,31 @@ The values defined can be accessed through the method <MethodReference type="Sta
163
173
|`select`| List of string values displayed as a Dropdown |
164
174
|`text`| Text Box |
165
175
176
+
#### Usage Example {/* #custom-settings-usage-example */}
177
+
178
+
```toml
179
+
[custom_settings]
180
+
max_props = { label = "Max Props", type = "integer", description = "maximum amount of props players can spawn", default = 1000 }
181
+
enable_pvp = { label = "Enable PVP", type = "boolean", description = "whether to enable PVP or not", default = true }
182
+
welcome_message = { label = "Welcome Message", type = "text", description = "message shown to players when they join", default = "have fun!" }
183
+
game_mode = { label = "Game Mode", type = "select", description = "which ruleset to use", default = "Classic", options = [ "Classic", "Hardcore", "Free for All" ] }
184
+
```
185
+
186
+
These are then exposed to every Package through <MethodReferencetype="StaticClass"class_name="Server"method_name="GetCustomSettings"show_class_name />, which returns a table keyed by the setting name and its raw value:
187
+
188
+
```lua
189
+
localsettings=Server.GetCustomSettings()
190
+
191
+
Console.Log(settings.max_props) -- 1000
192
+
Console.Log(settings.game_mode) -- "Classic"
193
+
```
194
+
195
+
They can also be overridden without touching `Package.toml`, either when creating a new game through the main menu, or by passing them directly on the command line, which takes precedence over both the New Game screen and `Package.toml` defaults:
0 commit comments