Code Monkey home page Code Monkey logo

terraria-tmodloader-server's Introduction

Buy me a coffee

 __  __     ______     __  __     __         ______
/\ \_\ \   /\  ___\   /\_\_\_\   /\ \       /\  __ \
\ \  __ \  \ \  __\   \/_/\_\/_  \ \ \____  \ \ \/\ \
 \ \_\ \_\  \ \_____\   /\_\/\_\  \ \_____\  \ \_____\
  \/_/\/_/   \/_____/   \/_/\/_/   \/_____/   \/_____/

Terraria & tModLoader server

This is a tModLoader server for Terraria PC, packaged as a docker image.


Docker Hub image:

hexlo/terraria-tmodloader-server:latest

Github image:

ghcr.io/hexlo/terraria-tmodloader-server:latest



Requirements

Server-side:

  • Docker
  • docker-compose

Client-side:

  • Terraria
  • tModLoader



General Config

  • Clone this repository
  • Create a docker-compose.yml file (see example below).
    You can otherwise rename docker-compose-example.yml to docker-compose.yml and modify it.
  • Edit the environment variables as you see fit. They are explained in a table further down.
  • Edit the enabled.json to include the mods you want. Check below for available mods.

docker-compose.yml example:

services:
  terraria-tmodloader-server1:
    # Github mirror: ghcr.io/hexlo/terraria-tmodloader-server:latest
    image: hexlo/terraria-tmodloader-server:latest
    container_name: terraria-tmodloader-server1
    restart: unless-stopped
    stdin_open: true
    tty: true
    ports:
      - 7782:7777
    volumes:
      - type: bind
        source: ./Worlds
        target: /root/.local/share/Terraria/ModLoader/Worlds/
      - type: bind
        source: ./enabled.json
        target: /root/.local/share/Terraria/ModLoader/Mods/enabled.json
    environment:
      - world=/root/.local/share/Terraria/ModLoader/Worlds/Calamity0.wld
      - autocreate=2
      - worldname=Calamity0
      - difficulty=1
      - password=calamity
      - motd="Welcome to hexlo's server! :)"
  • Launch the container. If you are using a command line interface (cli):
    docker-compose up -d



Creating and using Worlds

Using existing worlds

Terraria tModloader worlds are comprised of two files: a .wld and a .twld
If you have a Terraria tModloader compatible world already, you can simply put the two files in the Worlds directory.
Note: worlds created with terraria 1.4 or newer are not compatible with tModLoader's current version

Creating a new world

There is two ways to create a new world.

  1. Using variables in the docker-compose.yml file (recommended)
  2. By spinning a container, manually attaching to it and going through the command prompts of the terraria server.

1. Using variables in the docker-compose.yml file:

You need to set certain variables in the environment: part of the docker-compose.yml file, as follows:

...
    environment:
      - world=/root/.local/share/Terraria/ModLoader/Worlds/Calamity0.wld
      - autocreate=2
      - worldname=Calamity0
      - difficulty=1
...

Note: the description and possible values of these variables are described in a table below

2. Manually create a world:

You can create a new world or select different world served by a container by attaching to it.
docker attach <container-name>

  • press enter
  • Go through the options

To dettach without stopping the container: ctrl+p ctrl+q


Important!

If you want the server to start automatically on subsequent runs, you need to provide a world path to an existing world, by defining the environment variable world as shown in the exemple above.




Mods

Mods included in this image:

Note: If you would like mods that are not here, please let me know and I'll try my best to add them.

To enable or disable mods on the server, modify the enabled.json file with the names of the mods (the exact names as above). This needs to be done before starting the container.
Some mods may clash with each others, especially big content mods. Refer to the mod's wiki for more info.

enabled.json example:

[
  "BossChecklist",
  "MagicStorageExtra",
  "RecipeBrowser",
  "ThoriumMod"
]

Notes; The array of mod's names need the following properties:

  • The mod's names are exactly as they appear in the list above
  • The mod's names are in double quote
  • They are separated with a comma
  • There needs to be no trailing comma after the last item in the array

Important!

On the Client (your computer):

You need tModLoader to play on this version of the server. Download it through steam and keep it up to date.

On the server:

If the server gets out of date, make sure you recreate the container to update it.
Worlds and players created with 1.4 or newer will not work with this version of tModLoader.




Environment Variables

Note: These are case-sensitive!

Env variable Default value Description Example
world (empty) Path to your world. You need to provide a world for the server to start automatically world=/root/.local/share/Terraria/Worlds/My_World.wld
autocreate 2 Creates a world if none is found in the path specified by -world. World size is specified by: 1(small), 2(medium), and 3(large). autocreate=2
seed (empty) Specifies the world seed when using -autocreate seed=someseed123
worldname (empty) Sets the name of the world when using -autocreate. worldname=world1
difficulty 0 Sets world difficulty when using autocreate. Options: 0(normal), 1(expert), 2(master), 3(journey) difficulty=1
maxplayers 16 The maximum number of players allowed maxplayers=8
port 7777 Port used internally by the terraria server. You should not change this. port=8123
password (empty) Set a password for the server password=serverpassword
motd (empty) Set the server motto of the day text. motd="Welcome to my private server! :)"
worldpath /root/.local/share/Terraria/Worlds Sets the directory where world files will be stored worldpath=/some/other/dir
banlist banlist.txt The location of the banlist. Defaults to "banlist.txt" in the working directory. banlist=/configs/banlist.txt -> this would imply that you mount your banlist.txt file in the container's path /configs/banlist.txt
secure 1 Option to prevent cheats. (1: no cheats or 0: cheats allowed) secure=0
language en/US Sets the server language from its language code. Available codes: en/US = English de/DE = German it/IT = Italian fr/FR = French es/ES = Spanish ru/RU = Russian zh/Hans = Chinese pt/BR = Portuguese pl/PL = Polish language=fr/FR
upnp 1 Enables/disables automatic universal plug and play. upnp=0
npcstream 1 Reduces enemy skipping but increases bandwidth usage. The lower the number the less skipping will happen, but more data is sent. 0 is off. npcstream=60
priority (empty) Sets the process priority priority=1

Important!

  • If the world variable is left empty or not included, the server will need to be initialized manually after the container is spun up. You will need to attach to the container and select/create a world and set the players number, port and password manually. If you create a new world, it will be saved in the path defined by the environment variable worldpath.
  1. docker attach <container name>
  2. press enter
  3. Go through the options
  4. Detach from the container by pressing ctrl+p + ctrl+q
  • If, after creating your world with a specific seed, the server still doesn't initializes automatically, be sure to comment or remove the seed=<yourseed> variable in the docker-compose.yml file.



List of server-side console commands from the unofficial wiki

Once a dedicated server is running, the following commands can be run.
First, attach to the container with docker attach <container name>.


help - Displays a list of commands.
playing - Shows the list of players. This can be used in-game by typing /playing into the chat.
clear - Clear the console window.
exit - Shutdown the server and save.
exit-nosave - Shutdown the server without saving.
save - Save the game world.
kick <player name> - Kicks a player from the server.
ban <player name> - Bans a player from the server.
password - Show password.
password <pass> - Change password.
version - Print version number.
time - Display game time.
port - Print the listening port.
maxplayers - Print the max number of players.
say <message> - Send a message to all players. They will see the message in yellow prefixed with <server> in the chat.
motd - Print MOTD.
motd <message> - Change MOTD.
dawn - Change time to dawn (4:30 AM).
noon - Change time to noon (12:00 PM).
dusk - Change time to dusk (7:30 PM).
midnight - Change time to midnight (12:00 AM).
settle - Settle all water.

Banning and un-banning
The command ban <player> will ban the indicated player from the server. A banned player, when they try to login, will be displayed the message:You are banned for [duration]: [reason]- [modname]. A banned player may then be un-banned by editing the file "banlist.txt," which is located in the Terraria folder. This document contains a list of all currently banned players. To un-ban a player, delete the player's name and IP address from the list.

Note: no forward-slash / is needed before the command, as some command interfaces require.

terraria-tmodloader-server's People

Contributors

hexlo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.