# Don't Starve Together

# Configuration

Goes over the file structure and file based configuration options for DST servers

# Cluster Configuration

### <h3 style="color:#f6c177">Cluster.ini
The cluster.ini is the primary configuration file for cluster wide options. The server will look in `<persistent_storage_root>/<conf_dir>/<cluster>/` for the existence of this file. 

An example of the file
```ini
[GAMEPLAY]
game_mode = endless
max_players = 12
pvp = false
pause_when_empty = true

[NETWORK]
cluster_description = Silence Miranda
cluster_name = Mirandaville
cluster_intention = madness
cluster_password = password1234

[MISC]
console_enabled = true

[SHARD]
shard_enabled = true
master_port = 10889
```

<style>
table th:first-of-type {
    width: 20%;
}
table th:nth-of-type(2) {
    width: 14%;
}
table th:nth-of-type(3) {
    width: 40%;
}
table th:nth-of-type(4) {
    width: 30%;
}
</style>


#### <h4 style="color:#31748f">Gameplay
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|------------------------------------------|----------|-------------------------------|-----------|
|<p style="color:#907aa9">game_mode        |`survival`|`endless, survival, wilderness`|Sets the game mode: [Reference](https://dontstarve.fandom.com/wiki/Don%27t_Starve_Together)|
|<p style="color:#907aa9">max_players      |`6`       |`2, 4, 6, 8, 10, ...`          |No functional limit
|<p style="color:#907aa9">pvp              |`false`   |`true, false`                  |Enable/Disable player-vs-player
|<p style="color:#907aa9">pause_when_empty |`true`    |`true, false`                  |Wether the game will pause with no players online.




#### <h4 style="color:#31748f">Network
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|--------------------------------------------|-------------|----------------------------------------------|-----------|
|<p style="color:#907aa9">cluster_description|`empty`      |`Anything`                                    |The description of your server seen when someone selects your server in the server browser.
|<p style="color:#907aa9">cluster_name       |`None`       |`Anything`                                    |The name of your server seen on the server browser.
|<p style="color:#907aa9">cluster_intention  |`cooperative`|`cooperative, competitive, social, or madness`|Basically deprecated
|<p style="color:#907aa9">cluster_password   |`None`    |`Anything`                 |This sets the password people need to input to enter your server.


#### <h4 style="color:#31748f">Misc
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|---|---|---|---|
|<p style="color:#907aa9">console_enabled|`true`|`true, false`|DST runs with an interactive console that you can send commands to locally on the server itself. This option enables or disables that.|
|<p style="color:#907aa9">max_snapshots|`6`|`Any Integer`|Maximum number of snapshots to retain.


### <h4 style="color:#31748f">Shard
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|---|---|---|---|
|<p style="color:#907aa9">shard_enabled|`false`|`true, false`|Enables sharding, aka multi world. If you want caves enabled you need this, and the cave shard enabled.
|<p style="color:#907aa9">master_port|`10888`|`Any integer`|The port slave shards will connect to the master shard on.|



### <h3 style="color:#f6c177">Cluster Token
This file just contains a token that you generate from [Klei's Website](https://accounts.klei.com/account/game/servers?game=DontStarveTogether)

The server will look for the token in `<persistent_storage_root>/<conf_dir>/<cluster>/cluster_token.txt`

# Shard Configuration

### <h3 style="color:#f6c177">Server.ini
The server.ini is where the individual shards that comprise a cluster load their server side configurations from. The server will look in `<persistent_storage_root>/<conf_dir>/<cluster>/<shard>/` for the existence of this file. [Official Reference](https://forums.kleientertainment.com/forums/topic/64552-dedicated-server-settings-guide/)

An example of the file for the master shard:
```ini
[NETWORK]
server_port = 11000


[STEAM]
authentication_port = 8766
master_server_port = 27016

[SHARD]
bind_ip = 0.0.0.0
master_ip = 0.0.0.0
cluster_key = shardpassword1234
name = Master
is_master = true
```

<style>
table th:first-of-type {
    width: 20%;
}
table th:nth-of-type(2) {
    width: 14%;
}
table th:nth-of-type(3) {
    width: 40%;
}
table th:nth-of-type(4) {
    width: 30%;
}
</style>


#### <h4 style="color:#31748f">Network
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|------------------------------------------|----------|-------------------------------|-----------|
|<p style="color:#907aa9">server_port      |`10999`|`Any integer`|The UDP port that this server will listen for connections on. If you are running a multi-level cluster, this port must be different for each server on the same machine. This port must be between 10998 and 11018 inclusive in order for players on the same LAN to see it in their server listing. 


#### <h4 style="color:#31748f">Steam
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|------------------------------------------|----------|-------------------------------|-----------|
|<p style="color:#907aa9">authentication_port      |`8766`|`Any integer`|Internal port used by steam. Make sure that this is different for each server you run on the same machine.|
|<p style="color:#907aa9">master_server_port      |`27016`|`Any integer`|Internal port used by steam. Make sure that this is different for each server you run on the same machine.|

#### <h4 style="color:#31748f">Shard
|<p style="color:#b4637a">Name                                      |<p style="color:#b4637a">Default   |<p style="color:#b4637a">Options                        |<p style="color:#b4637a">Description|
|------------------------------------------|----------|-------------------------------|-----------|
|<p style="color:#907aa9">bind_ip      |`127.0.0.1`|`Public or Private IP`|This is the network address the master server will listen on for other shard servers to connect to. Set this to 127.0.0.1 if all of your servers in your cluster are on the same machine, or 0.0.0.0 if the servers in your cluster are on different machines. This only needs to be set for the master shard.|
|<p style="color:#907aa9">master_ip      |`none`|`Public or Private IP`|This is the I.P. address that a non-master shard will use when trying to connect to the master shard. If all servers in a cluster are on the same machine, set this to 127.0.0.1|
|<p style="color:#907aa9">cluster_key      |`none`|`Anything`|This is a password used to authenticate a slave server to the master. |
|<p style="color:#907aa9">name      |`none`|`Anything`|This is the name of the shard that will show up in log files. It is ignored for the master server, which always has the name [SHDMASTER].|
|<p style="color:#907aa9">is_master |`none`|`true, false`|Sets a shard to be the master shard for a cluster. There must be exactly one master server per cluster. Set this to true in your master server’s server.ini, and false in every other server.ini.|

# Runtime Configuration

### <h3 style="color:#f6c177">Runtime Options
These are flags you can pass to `dontstarve_dedicated_server_nullrenderer` that impact the server's behaviour.

<style>
table th:first-of-type {
    width: 20%;
}
table th:nth-of-type(2) {
    width: 14%;
}
table th:nth-of-type(3) {
    width: 40%;
}
table th:nth-of-type(4) {
    width: 30%;
}
</style>

These are the most common options

|<p style="color:#b4637a">Name                    |<p style="color:#b4637a">Default  |<p style="color:#b4637a">Description|
|-------------------------------------------------|----------|-------------------------------|
|<p style="color:#907aa9">persistent_storage_root |`~/.klei`|The directory that your configuration directory resides in. Has to be an absolute path.
|<p style="color:#907aa9">conf_dir      |`DoNotStarveTogether`       |Changes the name of the configuration directory.  Cannot contain slashes. This directory is what follows the perisstent_storage_root in your config path. `<persistent_storage_root>/<conf_dir>`
|<p style="color:#907aa9">cluster              |`Cluster_1`   |The directory specifies where your cluster configs will be (cluster.ini). It follows after the conf_dir `<persistent_storage_root>/<conf_dir>/<cluster>/cluster.ini`
|<p style="color:#907aa9">shard |`Master`    |Name of the shard you're launching. This also corresponds to where the shard configurations will be. `<persistent_storage_root>/<conf_dir>/<cluster>/<shard>/server.ini`

The full list can be seen here on [Klei's Site](https://forums.kleientertainment.com/forums/topic/64743-dedicated-server-command-line-options-guide/) (Though its likely out of date)

# Mod Configuration

### <h3 style="color:#f6c177">modoverrides.lua
Location: `<persistent_storage_root>/<conf_dir>/<cluster>/<shard>/modoverrides.lua`

This is the file that **enables** and configures mods for a particular shard. If you have more than one shard, and you want the enable the mod for both then you will have to edit two files:
```
<persistent_storage_root>/<conf_dir>/<cluster>/<shard_1>/modoverrides.lua
<persistent_storage_root>/<conf_dir>/<cluster>/<shard_2>/modoverrides.lua
```

This is an example of the file:
```lua
return {
        ['workshop-1947298962'] = { enabled = true },
        ['workshop-1615274304'] = { enabled = true },
        ['workshop-378160973'] = { enabled = true },
        ['workshop-2281925291'] = { enabled = true },
        ['workshop-2853529208'] = { enabled = true },
        ['workshop-361994110'] = { enabled = true },
        ['workshop-1595631294'] = { enabled = true },
        ['workshop-1898292532'] = { enabled = true },
        ['workshop-588560555'] = { enabled = true },
        ['workshop-1185229307'] = { enabled = true },
        ['workshop-1839858501'] = { enabled = true },
        ['workshop-2665334506'] = { enabled = true },
        ['workshop-1460627047'] = { enabled = true },
        ['workshop-1535658505'] = { enabled = true },
        ['workshop-2634350802'] = { enabled = true },
        ['workshop-1504778958'] = { enabled = true },
        ['workshop-1207269058'] = { enabled = true },
        ['workshop-2208128427'] = { enabled = true },
        ['workshop-2659067616'] = { enabled = true },
        ["workshop-352499675"] = { enabled = true,   --DST Resurrection Shelter
        configuration_options =
          {
            ["Mode"] = "Hard", 
            ["ShelterUses"] = 1000000,
            ["ShelterLight"] = "yes",
          }
        },
        ["workshop-385006082"] = { enabled = true, --DST Path Lights
        configuration_options =
          {
            ["path_lightrecipe"] = "normal", 
            ["light_color"] = "color4",
            ["FueledLights"] = "no",    
          }
        }
}
```

As you can see the configuration for individual mods uses internal names referenced by the mod itself making it hard to discover exactly what you need to type in, because of this I suggest booting up a local server with the mods configured the way you want them, and then inspect the file on your local machine and copy it over to the dedicated server. 


### <h3 style="color:#f6c177">dedicated_server_mods_setup.lua
Location: `<steam_install_dir>/mods/dedicated_server_mods_setup.lua`

This file is responsible for downloading and updating mods onto your server. You can either specify individual mods or collections.
```lua
--#Global Position
ServerModSetup("378160973")

--#Ancient Altar
ServerModSetup("481765222")

--#Health Info
ServerModSetup("375859599")

ServerModCollectionSetup("2865405455")
```

### <h3 style="color:#f6c177">modsettings.lua
Location: `<steam_install_dir>/mods/modsettings.lua`

This is purely for enabling mods. This can be done instead of using modoverrides.lua to enable mods across all shards, however it does not allow you to configure any of the settings that the mods would have.

```lua
-- Use the "ForceEnableMod" function when developing a mod. This will cause the
-- game to load the mod every time no matter what, saving you the trouble of
-- re-enabling it from the main menu.
--
-- Note! You shout NOT do this for normal mod loading. Please use the Mods menu
-- from the main screen instead.

-- ForceEnableMod("kioskmode_dst")


-- Use "EnableModDebugPrint()" to show extra information during startup.

EnableModDebugPrint()

ForceEnableMod("workshop-375859599")  --Health Info
ForceEnableMod("workshop-378160973")  --Global Positions
ForceEnableMod("workshop-382177939")    --DST Storm Cellar
ForceEnableMod("workshop-439115156")    --[DST] Musha [5.8 F]
ForceEnableMod("workshop-451559807")    --cave mod
ForceEnableMod("workshop-363989569")      --Growable Marble Trees
```

# DST Multihost Docker Server

Source: https://github.com/Kareth-io/dst-docker-multihost/