User Tools

Site Tools


setting_up_an_addon

About Addons

Addons are additional s&box content packs loadable in the context of a game. In this tutorial, we'll create an addon for Trouble of Terrorist Town so you can add code that changes the behavior of the game - whether it be custom weapons, custom roles, or something else entirely.

If we're making an addon, let's get started!

Before creating an addon, you'll need:

  1. At least some knowledge of C#. s&box and the game's addons are written in C#. C# tutorials are available at the MSDN.
  2. A copy of the game redeemed to your Steam account and installed.
  3. Your favorite IDE set up. Full-fat Visual Studio is usually the preference here as it provides the best Intellisense and the most features, but you can also use Visual Studio Code (if you hate yourself) or JetBrains Rider. Instructions on setting up your IDE with s&box are available on the s&box wiki.

Open the game in tools mode

By default, Steam will prompt you to select which mode to launch s&box in when you start the game from your Library. If Steam does not prompt you to start in “Game Editor” mode, follow these steps to enable it again:

  1. Right click s&box in your Steam library, and then click Properties.
  2. Under General, find Launch Options, and ensure that the dropdown has Ask when starting game selected.
  3. Now, you'll be able to click Play as normal and see Launch Game Editor.

Creating your addon

Once you have tools mode open and can see the Welcome screen, you can create your first addon.

  1. Click Content Mode at the top left of the screen.
  2. You'll now see the game's normal menu screen with a bunch of information panels around it. For more information about what these panels are and what they're used for, see the s&box wiki. For now, we're just interested in creating a new project, so click File at the top left and then New Project…
  3. Select Addon at the top left of the top left of the screen that pops up, and fill out the information that is asked for.
    1. The Title is a user-visible title for your addon. For example, you might want to call this “My Cool Overpowered Gun (TTT)”
    2. The Ident is a machine-visible title for your addon. For example, you might want to put “overpowered_gun” here.
    3. The Location is where your addon's files will be stored. Where you decide to place your addon is largely up to you.
    4. The Create .gitignore option controls whether a file for used with the Git version control system is created. The file tells Git which files should not be checked into version control. You probably want to keep this checked, unless you know what you're doing.
  4. Click Create. Your new project will show up on the left in the Projects pane. In order to your addon work with TTT, we'll need to make a quick change - first, right click the addon in the Projects pane and then click Project Settings…
  5. Under the Project Setup menu, under the Target Game option, click the folder icon, and then click From asset.party to pick an addon from asset.party.
  6. Find Trouble in Terrorist Town! (TTT) by Three Thieves in the menu. You may need to search for it. Then select it and click OK. This will select Trouble in Terrorist Town! (TTT) as the Target Game.
  7. Click Save and close the window - your addon is now set up for TTT. Finally, we'll set up a Launch Configuration to make loading the game with your addon easy.
  8. Above the game menu, at the top left, you'll see a dropdown next to a Play button, Stop button, and a Menu button. Click it and select Edit Launch Configurations to add a launch configuration for your addon.
  9. On the left, at the bottom, click Create New Config. Then fill out the form as follows:
    1. The Configuration Name field controls what the configuration is titled in your editor.
    2. The Game field controls what game this launch configuration is for. Click the folder icon to the right of the dropdown, then click From asset.party. Find Trouble in Terrorist Town! (TTT) by Three Thieves in the menu. You may need to search for it. Then select it and click OK. This will select Trouble in Terrorist Town! (TTT) as the Game.
    3. The Map field controls what map is loaded when running this launch configuration. Popular maps for debugging include dev/preview_flat (local) or Rooftops (from asset.party). Use the folder icon to select a map, or keep the default of Square.
    4. The Maximum Players field controls the number of players that can join games launched with this launch configuration. It is recommended to set this to at least 8, so that bots are allowed to join the game (they consume player slots like real players).
    5. The Pre Launch Command allows you to specify concommands to run before launching the game. We can leave this blank for now.
    6. The Post Launch Command allows you to specify concommands to run after launching the game. You may want to disable the automoderator and idle spectator timeout - you can do this by entering ttt_idle_timeout 999999; ttt_automoderator 0 in this field.
    7. The Addons field controls which addons are loaded when the game is launched from this configuration - this is the most important part. Click the folder on the right and select your newly-created addon from the list.
  10. Click Save and close - now we're ready to launch the game and start coding! Select the launch configuration you just created from the dropdown and then click the Play button. The game will load and your addon will be enabled!

Writing your addon's code

You can open the addon in your preferred code editor by right clicking it in the Projects pane. From there, you'll be able to create C# files and write code as usual.

Two things that you might want to do (but anything is possible in theory):

When you save your code, s&box will automagically compile it and load it in the game. With a few exceptions, your changes will be visible immediately.

Publishing your addon to asset.party

Once you've finished writing and testing your code, you can upload it to asset.party in order to allow players to select it when creating a lobby or dedicated server.

  1. Right click your project in the Project Settings pane, and then click Project Settings to open the project settings menu.
  2. Select Upload To Asset Party in the menu on the left.
  3. Confirm your ident as created earlier in this guide, and select the organization you want to publish it under. If you haven't already created an organization, do so by selecting the “Create New Organisation” option and restart the game before continuing.
  4. Confirm that all of the files that you want to upload show in this screen, then click Upload Files.
  5. Provide a change title and optional description, then click Publish New Revision.
  6. Congratulations, your addon is now on asset.party! You can click View and Edit on Web to view and edit the addon on asset.party.
setting_up_an_addon.txt · Last modified: 2023/07/31 03:03 by antigravities

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki