Skip to content

Commit 32c17cb

Browse files
committed
Update project-settings.md
1 parent 406ab79 commit 32c17cb

File tree

1 file changed

+48
-34
lines changed

1 file changed

+48
-34
lines changed

docs/en/manuals/project-settings.md

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,47 @@ Every setting in the file belongs to a category. When you open the file Defold p
1111

1212
![Project settings](images/project-settings/settings.jpg)
1313

14-
Below are all the available settings, arranged by section. Some settings are not yet exposed in the settings editor (these are marked "hidden setting" below), but can be set manually by right clicking *game.project* and selecting <kbd>Open With ▸ Text Editor</kbd>.
14+
15+
## File format
16+
17+
The settings in *game.project* are usually changed from within Defold, but the file can also be edited in any standard text editor. The file follows the INI file format standard and looks like this:
18+
19+
```ini
20+
[category1]
21+
setting1 = value
22+
setting2 = value
23+
[category2]
24+
...
25+
```
26+
27+
A real example is:
28+
29+
```ini
30+
[bootstrap]
31+
main_collection = /main/main.collectionc
32+
```
33+
34+
which means that the setting *main_collection* belongs to the *bootstrap* category. Whenever a file reference is used, like the example above, the path needs to be appended with a 'c' character, which means you're referencing the compiled version of the file. Also note that the folder containing *game.project* will be the project root, which is why there is an initial '/' in the setting path.
35+
36+
37+
## Runtime access
38+
39+
It is possible to read any value from *game.project* at runtime using [`sys.get_config_string(key)`](/ref/sys/#sys.get_config_string), [`sys.get_config_number(key)`](/ref/sys/#sys.get_config_number) and [`sys.get_config_int(key)`](/ref/sys/#sys.get_config_int). Examples:
40+
41+
```lua
42+
local title = sys.get_config_string("project.title")
43+
local gravity_y = sys.get_config_number("physics.gravity_y")
44+
```
45+
46+
::: sidenote
47+
The key is a combination of the category and setting name, separated by a dot, and written in lowercase letters with any space characters replaced by underscores. Examples: The field "Title" from the "Project" category becomes `project.title` and the "Gravity Y" field from the "Physics" category becomes `physics.gravity_y`.
48+
:::
49+
1550

1651
## Sections and settings
1752

53+
Below are all the available settings, arranged by category.
54+
1855
### Project
1956

2057
#### Title
@@ -148,9 +185,15 @@ Clear color alpha channel, used by the render script and when the window is crea
148185
#### Type
149186
Which type of physics to use, `2D` (default) or `3D`.
150187

188+
#### Gravity X
189+
World gravity along x-axis, `0` by default.
190+
151191
#### Gravity Y
152192
World gravity along y-axis, `-10` by default (natural gravity)
153193

194+
#### Gravity Z
195+
World gravity along z-axis, `0` by default.
196+
154197
#### Debug
155198
Check if physics should be visualized for debugging.
156199

@@ -160,12 +203,6 @@ Alpha component value for visualized physics, `0`--`1`. The value is `0.9` by de
160203
#### World Count
161204
Max number of concurrent physics worlds, `4` by default. If you load more than 4 worlds simultaneously through collection proxies you need to increase this value. Be aware that each physics world allocates a fair amount of memory.
162205

163-
#### Gravity X
164-
World gravity along x-axis, `0` by default.
165-
166-
#### Gravity Z
167-
World gravity along z-axis, `0` by default.
168-
169206
#### Scale
170207
Tells the physics engine how to scale the physics worlds in relation to the game world for numerical precision, `0.01`--`1.0`. If the value is set to `0.02`, it means that the physics engine will view 50 units as 1 meter ($1 / 0.02$). The default value is `1.0`.
171208

@@ -610,30 +647,6 @@ If checked, enable CPU profiling in release versions of the builds. Normally, yo
610647

611648
---
612649

613-
## File format
614-
615-
The format of the settings file is simple text (INI format) and can be edited by any standard text editor. The format looks like this:
616-
617-
```ini
618-
[category1]
619-
setting1 = value
620-
setting2 = value
621-
[category2]
622-
...
623-
```
624-
625-
A real example is:
626-
627-
```ini
628-
[bootstrap]
629-
main_collection = /main/main.collectionc
630-
```
631-
632-
which means that the setting *main_collection* belongs to the *bootstrap* category.
633-
Whenever a file reference is used, like the example above, the path needs to be appended with a 'c' character, which means you're referencing the compiled version of the file.
634-
Also note that the folder containing *game.project* will be the project root, which is why there is an initial '/' in the setting path.
635-
636-
637650
## Setting config values on engine startup
638651

639652
When the engine starts, it is possible to provide config values from the command line that override the *game.project* settings:
@@ -643,13 +656,14 @@ When the engine starts, it is possible to provide config values from the command
643656
$ dmengine --config=bootstrap.main_collection=/my.collectionc
644657

645658
# Set two custom config values
646-
$ dmengine --config=test.my_value=4711 --config=test2.my_value2=1234
659+
$ dmengine --config=test.my_value=4711 --config=test2.my_value2=foobar
647660
```
648661

649-
Custom values can---just like any other config value---be read with [`sys.get_config()`](/ref/sys/#sys.get_config):
662+
Custom values can---just like any other config value---be read with [`sys.get_config_string()`](/ref/sys/#sys.get_config_string) or [`sys.get_config_number()`](/ref/sys/#sys.get_config_number):
650663

651664
```lua
652-
local my_value = tonumber(sys.get_config("test.my_value"))
665+
local my_value = sys.get_config_number("test.my_value")
666+
local my_value2 = sys.get_config_string("test.my_value2")
653667
```
654668

655669

0 commit comments

Comments
 (0)