Starmadepy is a simple python library that makes parsing and manipulating Starmade game data easy. The only file type that is currently supported is the .smtpl
, or Starmade Template file type. This library allows you to read and write starmade files, and make all sorts of programmatic modifications to them. Read on to see some examples of it’s usage.
For this project I had to reverse engineer the file formats and then build out the Serialization/Deserialization in Python.
Starmade is a block building game a lot like Minecraft, only it’s in Space! Players often build Sci-Fi like Spaceships and Space Stations. In the process of building these creations, players may find themselves repeatedly building some of the same structures over and over. To solve this problem, Starmade allows for the creation and usage of Templates. Templates are just configurations of blocks that can be reused in many places; Starmade saves these templates as .smtpl
files. (They also contain some information about Logic Circuitry that may be included but for the sake of this article I’ll ignore it)
One of the drawbacks of those templates, was that they just stored configurations of blocks, and those blocks had a color associated with them. This meant if you wanted different color components you had to make a new template for each and every color you wanted. This was extremely tedious in game. That’s where Starmadepy could come in!
With starmadepy you could write a python script that handled generating all of the desired color variations out of a single template file! Let’s take a look at an example.
In this example we’re going to have a little gray compnent stored in a template file called sometemplatefile.smtpl
, and we’re going to try and generate an orange version of it and save it as outtemplatefile.smtpl
from starmadepy import starmade
template = starmade.Template.fromSMTPL('sometemplatefile.smtpl')
template.replace({'color': 'grey'}, {'color': 'orange'})
template.save('outtemplatefile.smtpl')
This would give us the following result: