Docs

Existing mods are available on the Steam Workshop Page

Forum Threads

Code

Please don’t hesitate to email me at arthur@anisopteragames.com with any questions.

Reassembly Modding

This document describes the process of creating mods for the game Reassembly and documents
the data file formats loaded by the game.

A “mod” in Reassembly is essentially a directory containing modified data files. Mods data files are in the same format and may override any of the data files packaged with the game – the exact method by which mod data overrides or is merged with package data and other mod data is dependent on the data type and is described below.

Reassembly data files are in plain text format. I recommend Notepad++ for editing these files. I personally prefer GNU emacs but the learning curve is pretty steep.

Mod Creation Overview

Faction Export Method

Reassembly can export an existing save slot as a mod that adds the ships from that save slot as a new faction. The ship files can either use blocks from the parent faction or, optionally, a new set of blocks can be automatically created from the parent blocks and then modified by the modder. From the save slot selection screen (right after Start from the main menu), right click on the slot and select “Export as Mod” or “Export as Mod (create blocks.lua)”. If you elect create blocks.lua, you can then edit this file to change block statistics – see the section on Block creation below. The resulting mod should be immediately visible in the mod browser and can be published – although the game will need to be restarted to allow playing as or against the new faction.

Custom Method

  1. Create a folder called “mods” alongside the “data” folder in the system save location
    Windows: C:/Users/You/Saved Games/Reassembly/
    Mac: /Users/You/Library/Application Support/Reassembly/
    Linux: /home/You/.local/share/Reassembly/

  2. create a folder for your mod inside this directory (e.g. …/Reassembly/mods/mynewmod/)

  3. copy and modify files from the “data” directory into this folder as appropriate
  4. Your mod will be automatically loaded when the game starts and should be visible in the “mods” menu as a local mod. Test the mod to make sure you are happy with it. Be sure to check the log for any errors in loading your mod.
  5. Use the “Publish” button in the “mods” menu to upload the mod to the Steam Workshop. This should open the workshop web page for your mod, allowing the title and description to be edited.
  6. The “Publish” button may be used again to upload revisions to your mod. Keep in mind that any changes will be downloaded by your mod’s subscribers – try not to break backwards compatibility.

Moddable files

Reassembly’s data files can be overridden or extended via mods.

An important component of the mod system is the ability to support multiple simultaneous mods.
Since many things in Reassembly are referenced using numeric identifiers and it would otherwise
be easy for multiple mods to accidentally pick the same identifiers, mods undergo a process
called Relocation when they are loaded
from the Steam Workshop. The details of this are described below.

Data syntax

Reassembly data files are all parsed using the same system and have the same basic syntax, which is inspired by the programming language Lua. The exact format of each file depends on its contents. All data files are utf-8 encoded.

Comments – instructional text that is ignored when loading – start with ‘#’ or ‘–‘ and extend to the end of the line.

Data is strongly and strictly typed (like in C++, unlike Lua). For example, the “points” field within Block definitions is of integer type. Therefore, ‘points=5.6’ is a syntax error, as is ‘points=”5.6″‘. A correct definition would be ‘points=5’.

See the Appendix for complete data type definitions.

Since it is relatively easy to misplace a comma or brace, be sure to check the game log for
syntax errors while testing your mod.

Blocks – blocks.lua

Block mods can create new blocks or modify existing blocks. New blocks can be added to one of the base factions or attached to new factions.

By default blocks are built into the game binary. To generate blocks.lua, set cvar
(kWriteBlocks=1) and restart the game. The best way to learn about the block file format is to
study the descriptions for familiar weapons in this file.

The block file format syntax, like other Reassembly data files, is inspired by the programming
language Lua. This is the description for the basic Plasma Cannon – a relatively small,
octagonal, turreted projectile weapon.

Block Identifiers

The first and most important element of a block description is the block identifier – in this
case 881. Ship and save files containing the block will refer to the block by this number only.
In general, changing the shape or size of the block will cause ships containing that block to
load incorrectly. Certain block identifiers are “relocated” by the modding system for Steam
Workshop mods to avoid conflicts between mods adding new blocks. Relocation essentially adds a
per-mod id number to each new block in the mod.

New blocks (including new blocks added to default factions) should be given id numbers between 1
and 199. If you need to add more than 200 blocks, use numbers between 17000 and 26000.

The range 200-17000 is reserved for built-in default blocks and mods defining blocks within this
range will overwrite those blocks. Mods modifying default blocks, should be careful not to change
the blocksize or blockshape of the block to avoid breaking existing ships.

Block fields

Blockshape and blockscale together specify the shape and scale of a block. A list of all shapes
will be written to the log when kWriteBlocks=1. The durability and density fields are multiplied with
the area of the block to calculate the health (hit points) and mass of the block, respectively.
Although health may be specified, it is always overridden by the value computed from durability.

Colors are in hexadecimal RRGGBB format – the same as HTML or CSS colors except with a 0x prefix
instead of #. The color of each block slowly phases between fillColor and fillColor1. Certain colors (e.g. laser color) contain an alpha component AARRGGBB where 0xff is fully opaque and 0x00 is fully transparent.

The P value of a block may be specified as “points”. Otherwise, it is calculated based on a number of other fields. There are also several
fields that will be calculated if no value is provided. Auto-calculated fields include cannon and
laser power, generator powerCapacity, shield and thruster color, color, block grow rate, resource
capacity, durability, and density.

The group field should be set to the faction to which the block belongs. To make a block
purchasable in the Upgrade / Data Bank screen, it must also be used in a ship in that faction –
see the next section.

Factions – factions.lua, ships/, extra_ships/

Ship files loaded from the ships/ directory must have the form _.lua,
as in “8_interceptor.lua”. Ships are indexed by name in much the same way that blocks are indexed
by block identifier number – therefore, mods that add a new ship with the same name and faction
as a default ship will overwrite that default ship. To avoid conflicting with other mods, ships
added to default factions should avoid generic names and consider including the name of the mod
or mod author in the name.

New faction should be assigned numbers between 20 and 100. Faction numbers in this range are
subject to relocation in the same manner as block ids – when the mod is installed through Steam
Workshop the mod identifier will be added to the faction number to create a new, unique faction
number. Therefore, multiple mods may e.g. define faction 20 without fear of conflicting.

The file factions.lua describes faction data not in the ships themselves. The “color0” and
“color1” fields are used in combination with block colors when the player changes their faction
color. The “aiflags” field describes the default ai behavior of ships in this faction –
individual ships are also subject to behavior randomization. Factions with “playable=1” will show
up on the faction select screen, and the “start” field specifies the starting player ship for
that faction. “playable=2” indicates that the faction is unlocked by default.

Ships loaded from the extra_ships/ directory are added to faction 10 (set by kExtraShipsFaction).
The file name need not follow the same format as ships loaded from the ships/ directory.

New faction mods must also add their faction to regions.lua – see the Map section.

Audio – audio.lua, audio/

The audio.lua file defines sound effects and music files used by the game. The format of this file is documented in comments of audio.lua – there are many different events that are played at various points in the game. Sound samples are in Ogg Vorbis format.

Mods may override individual samples by creating the relevant file in the audio/ directory. They may also provide an audio.lua file which defines new samples or settings for particular audio events. Audio events are merged between mods so an individual mod should only override changed events.

Shaders – shaders.lua, shaders/

Reassembly loads GLSL version 1.2 shaders from this file which mods can override. Files are
merged together by key so mods should only define shaders that they change. Shaders can #include
files from the shaders/ directory for convenience.

Text – messages.lua, popups.lua, tips.lua, text.lua

These files define text that shows up in various places in the game. Text files loaded by mods
are merged with the default versions and with other mods so mod authors should only place new
contents in these files.

The text.lua file is the only one not present in the base game directory. This file allows
replacement of hard-coded game text and is intended for localization style mods. For example, to
replace the “Start” button on the main menu with a “Play” button:

Map – regions.lua

The regions.lua file is used to generate the map when a new game is created. It is also
referenced as individual sectors are explored and generated. A “region” is a group of map sectors
that are generated with the same parameters. There is typically at least one region per faction,
but there may be several and region may generate more than one faction of ships or no ships at
all. During generation, each region definition is expanded into several regions, each of which
covers at least one sector. A description of which region definition corresponds to each sector
is then written to map1.lua in the save directory.

A mod can either completely redefine this file or add a new region to the default contents. Mods
that completely redefine the file are subject to extension by additive mods but two mods can not
simultaneously redefine the file. Mods which primarily add new factions are encouraged to extend
rather than replace to avoid conflicting with other faction mods.

The regions.lua file parses a single recursive Region definition structure. If the top level
region defines the totalSize parameter, it will replace the whole region definition. Region mods
that do not define totalSize will be merged with the existing region.

Region Definition Fields

The “ident” field uniquely identifies the region and is stored in the save game directory (in
map1.lua). As with block and faction ids, mods should avoid changing region identifiers as doing
so can break existing save files. Region identifiers are subject to relocation in the same manner
as block idents and faction numbers.

“count” determines the number of actual regions generated by this definition. “radius” and
“position” are both in the range [0-1] and specify ranges for the radius of each generated
region and its distance from the origin of the containing region, respectively.

The “fleets” field defines a P curve for ships generated by each faction – in this case sectors
at radius 0 from each region (i.e. the center) will generate 1000P of ships and sectors at the
edge will generate 600. See the regions.lua file for documentation and examples of other region fields.

Font – blockfonts/, *.ttf

Both the in-world block fonts and the GUI TrueType fonts are moddable.

In-game block fonts are used most prominently to write “Reassembly” on the title screen. Fonts
can be created or modified in in the sandbox with the “sfont” console command. Use the “write”
command to add text to the game. There can be several fonts – the default font is “def”.

Reassembly uses five separate ttf fonts for drawing text in GUIs. There is the default font, a
title font, a monospace font, a fallback font for additional language support, and a symbol font.
To change these fonts, include the new .ttf font file in your mod directory and set the relevant
cvar (e.g. kDefaultFontFile, kTitleFontFile…) in your mod’s cvar.txt to the filename of the
.ttf file.

Misc – cvars.txt

Cvars are a general mechanism for modifying game variables. They can be loaded from a file or changed via the console “cvar” command. Many aspects of the game can be changed through cvars, for
example the P cap (kPointMax), various C rewards and costs (kConquestC, kWormholeC,
kRecruitCostC, …), graphics settings (kWorleyColorRadius, kProjectileGlow, kProjectileHalo),
and many other things.

cvars are conventionally named kWhatDoesItDo. See cvars.txt for a complete list of available variables – this file is written to the system save directory on startup if it has not been modified. Cvars can also be set via the console command “cvar”. Individual cvars are documented on the Sandbox/console/cvar command reference page.

Appendix

Data type definitions. Values default to 0 unless otherwise specified.

int is an integer (-1, 0, 1…)

uint is an unsigned integer (0, 1, 2…)

float is a floating point (real valued) number (-1.5, 0, 1.5). 1, 1.0, and 1.000000 are all valid
floats representing the same number.

float2 and int2 are 2d vectors of float and int type respectively represented as {x, y}. A single value x means {x, x}.

List is a list with all elements of type T. Represented as {element0, element1, …}

Pair<T, U> is two items of type T and U, represented as {itemT, itemU}

structs are parsed as {field0=val0, field1=val1…}, fields may be in any order
Blocks are uniquely parsed as {ident, offset, angle, field0=val0, field1=val1…}

enums except for Shape define bitsets that are parsed as VAL0|VAL1|VAL2…

58 thoughts on “Docs

  1. whenever i try to load my mod, error text came up saying that it dose not have a starter ship. so i went into sandbox and open the palette for the modded blocks and its showed that there is no palette by my factions name

  2. How would i go about making a launcher that replicates a specific design? i tried to do a “replicate=*Core block with blueprint*”, but the error message tells me that the block i am replicating is somehow overwriting itself?

  3. I’m having trouble making new ships with modded blocks. I created a mod that adds several weapons, and they don’t show up in the in-game pallet for purchase. I’ve been advised to create a ship for each faction that uses my blocks in order to make them show up. However, when I attempt to save a ship in the sandbox, it simply tells me. “Error saving: ‘(null)’ : Can’t save relocated ship. [DESERIALIZE] Lost _ blocks patching. (Cl_0: 265, 0P)”. I’m using the ssave tool. That’s as much information as I currently can give you. Thanks!

    • This error message means that the ships you are saving use blocks from a steam workshop mod (relocated blocks). Your mod ships should contain only blocks from your mod and built in blocks. You can identify steam workshop blocks because they have very large id numbers (million+).

      Also don’t forget to give the ship a name when you save it: “ssave warlord” to name it warlord.

        • If your block is not showing up in the “palette” or “minpalette” sandbox commands, most likely there is a syntax error in your blocks.lua. Check the log for your mod (in the mods screen). Also, make sure that the “group” field of the block is set to the correct faction number.

          If your block shows up in the “palette” command but not in the in-game databank, this is most likely because your faction does not have a ship using that block. Only blocks which are used in a ship show up.

  4. I’m trying to boost my p in a world (not mod it higher, give myself more instead of collecting r and buying it) and i don’t see any obvious save files in there specifically to edit. For mac users, how do I get there and edit the value within the save?
    Thanks!

  5. i’m on a mac and i’ve edited the cars.txt so that kWriteBlocks=1 but blocks.lua is not generating. can anyone help?

      • I may be a bit late, but you may be looking in the wrong data file. There is a data file located in C:\Users\(ComputerNameHere)\Saved Games\Reassembly\data. The “blocks.lua” and “blockstats.lua” should be written to this folder. If not, make sure you still have kWriteBlocks still equal to 1 in your cvars.txt, and launch your game. Upon closing it, it should generate.

  6. I tried to ssave my palette ship as what the SANDBOX TUTORIAL page said, but it warned that “cannot save relocated ship”. How could I fix it? Nothing else seems to be wrong. Thanks.

    • This means that the ship contains blocks from a steam workshop mod. Make sure the ship only contains default blocks, or blocks from a local mod that the ship is part of.

    • It uses the same scheme as other colors.

      Colors are represented internally as “unsigned int” and when they are printed it either uses hex (0x123abc) for very large numbers or decimal (123456) for smaller numbers. Some colors, for example pure dark blue (0x000040) are below the decimal threshold and come out like “64” instead.

  7. I have no idea what the problem is, so I included as much information as possible. I am making a mod that involves custom blocks with custom names. everything else about the mod works except the blocks, all I get is the default block selection with the default names (some of those blocks shouldn’t be included in the mod). all I tried to change was some reload times and damage numbers. here is an example of what Im doing and what I want to happen

    {10, bindingId=2, shape=RECT_LAUNCHER, name=”Plasma Torpedo Launcher”, features=LAUNCHER,
    group=20, points=21, durability=0.500, blurb=”Launches homeing plasma torpedos”, density=0.150,
    fillColor=0x067381, fillColor1=0x067381, lineColor=0x067381, thrusterColor=0xc204d5,
    thrusterColor1=0x4d4d4d, replicateBlock=
    {command={}, shape=MISSILE, features=COMMAND|THRUSTER|TORQUER|EXPLODE, group=20,
    lifetime=10.000, points=2, durability=0.400, density=0.150, fillColor=0x073485,
    fillColor1=0x644491, lineColor=0xc470f3, capacity=100.000, thrusterForce=2600.000,
    thrusterColor=0x90611069, thrusterColor1=0x90985fa8, torquerTorque=4000.000,
    explodeDamage=30.000, explodeRadius=25.000}, replicateTime=1.500, launcherPower=20.000,
    launcherOutSpeed=50.000}

    there is no indication in game that anything I did here changed anything.

    what am I doing wrong and how do I fix it?

  8. I don’t know what I did wrong, but a new mod I’m working on just refuses to work, I’ve done absolutely everything I can think of, but it gives me a simple error about not locating a “{” at the start of the file (line 0), even though it is literally “{}” right now…

      • exact same error

        {

        {94, bindingId=1, shape=CANNON, scale=4, name=”POOSHKA”,
        features=CANNON, group=20, points=482, durability=0.250, blurb=”BOOM”,
        density=0.150, fillColor=0x113077, fillColor1=0x1e4c79, lineColor=0x3189eb, thrusterColor=0xececec,
        thrusterColor1=0x4d4d4d, cannon={roundsPerSec=0.500, explosive=FINAL, muzzleVel=1800.000,
        power=316.000, damage=50000.000, color=0x5a8e9, range=3000.000, explodeRadius=50000.000}}

        • {
          {94, bindingId=1, shape=CANNON, scale=4, name=”POOSHKA”,
          features=CANNON, group=20, points=482, durability=0.250, blurb=”BOOM”,
          density=0.150, fillColor=0x113077, fillColor1=0x1e4c79, lineColor=0x3189eb, thrusterColor=0xececec,
          thrusterColor1=0x4d4d4d, cannon={roundsPerSec=0.500, explosive=FINAL, muzzleVel=1800.000,
          power=316.000, damage=50000.000, color=0x5a8e9, range=3000.000, explodeRadius=50000.000}}
          }

          Sorry if I’m a bit late! You forgot a closing bracket to complete your code.

  9. I Have a Question, I created a block it has no errors i am pretty pleased with that but when i go in a game with my mod my created blocks it not in Upgrades or pallete D: If semone could explain me why or what i have done wrong please answer , Thanks 🙂

    • Also, I’m getting the error /blocks.lua:0 expected ‘{‘ while parsing SerialBlock
      I assume it has something to do with me missing a { somewhere, but I can’t find anything, I have this (Just added on to the end of an exported save with Blocks.lua):
      {78,}, …..
      {79,},
      {80, bindingId=1, name=”Cytoscrambler”, features=TURRET|LASER|CHARGING, group=21,
      <>},
      {81, bindingId=1, name=”Plasma Blade”, features=MELEE, group=21,
      <
      >},
      {82, bindingId=1, scale=2, name=”Molecular Dissasembler”, features=TURRET|LASER|CHARGING, group=21,
      <
      >}}

      • The error is on the very first line (hence the : 0). I think I am seeing the just end of the file but blocks.lua needs to start with a {, since it represents a list of blocks. So:

        {
        {78, name=”foo”},
        {79, name=”bar”},
        }

        Something like that. There error looks like it saw the first { and then found something other than a { when trying to read the first block.

    • Burstyness, together with roundsPerSec (*average* rounds fire per second) and roundsPerBurst, controls when projectiles come out of cannons. A cannon with burstyness of 0 fires at a constant rate. A cannon with burstyness of 1 fires all rounds in the burst simultaneously, like a shotgun. Burstyness of 0.5 spends half of the cycle time firing and half waiting.

      Burstyness can also apply to pulse lasers, of which pulseAvailability is a also a property. PulseAvailability defines the fraction of time that the laser is on – i.e. the length of each pulse. 0.5 means that each pulse of time t if followed by the laser being off for time t. Other properties that control laser pulsing are pulsesPerSec (analogous to roundsPerSec), pulsesPerBurst (analogous to roundsPerBurst), and burstyness.

    • I do believe its possible, but I don’t know how to. At the bottom of C:\Users\(ComputerNameHere)\Saved Games\Reassembly\data, you should see shapes.lua. This contains code that defines the points at which the shapes can be attached, as well as the defining parts of the actual shape.

  10. Is it possible to edit modules in mods?

    Say for example if a mod contains a turret module that works fine, but for some reason has max rotation speed and no energy cost, how would I add the energy cost and tone down the rotation?

    • Also, is it possible for modded fleets to get uploeaded as agents into other players games? Even if the “victim” does not have mods?

  11. Alright so I have some questions:
    1: When making a block, does it matter the order in which you add the component text in? Do you type the shields after the cannon? Or before? Because I once added in a shield on an existing block and it broke the game.
    2: How do you get buildings to spawn? I have a design that uses a block with a root feature (no thrusters). I put it in a ships folder with all the other ingame ships. It just spawns as a station, not a building. It was a faction 2 design (maybe you have to set something for it to spawn as a building?)

    • 1. The order doesn’t matter – if you get a combination that doesn’t work check the log for error messages and if you still can’t get it to work send me an email with the block description.
      2. Game should detect/spawn buildings automatically. The root block needs to be oriented correctly (yellow port towards asteroid). You also need to change the faction region definition in regions.lua to set ambient = {-1} (see the definitions for the faction 6 and 12).

      • Ok, so the regions thing worked but wasn’t such a good idea for faction 2 as the buildings also spawned on the station’s environmental armor blocks too. The game crashed 😛

  12. Pingback: Reassembly Adds Mod Support Via Steam | IndieHangover

  13. Your mod will be automatically loaded when the game starts and should be visible in the “mods” menu as a local mod. Test the mod to make sure you are happy with it. Be sure to check the log for any errors in loading your mod.

    There is no “mods” menu?

  14. Pingback: Reassembly, les mods maintenant disponible ! | spaceunivers.com

Leave a Reply