In my spare time I poke around developing the Dectorio mod for the game Factorio. If you aren't aware of what Factorio is, it's basically a factory building simulator where you have crashed on an alien planet and you are tasked with building your way off it by ultimately launching a rocket. It's truly one of the greatest games I've ever played so you should definitely check it out if you're interested. Here's a quick video to whet your appetite...

I'm guessing if you're still reading you're familiar with the game. One of the challenges with developing mods for Factorio is you end up in the situation where you need to be able to test multiple configurations and game setups without resorting to constantly relying on other people to test it for you. One of the most difficult scenarios to test is multiplayer, as it requires you to run at least two copies of the game simultaneously. On Windows this is an easy proposition as the game developers provide a simple zip version of the game that will run as a standalone copy, however on Mac, the only version available is a pre-packaged disk image that will complain when you try to run a second copy.

The reason it does this is because the game stores it's configuration in your user's Application Support folder and so when you have multiple copies trying to access these files at the same time, it won't allow you to start the game. Initially I spent quite some time searching through the Factorio Forums to see if anyone else had managed to solve this and although there were old references here and there, nothing I could find would actually work. After a bit of mucking around, I uncovered there is a solution to this though!

Step 0: Install the Steam version of Factorio

The Steam version of Factorio will be your first copy of the game, so make sure you have that set up and ready to go. Once you've done that, you can follow the steps below to get your second copy to run alongside the Steam version.

Step 1: Download the dmg file from the Factorio website

You'll need to head to https://www.factorio.com/download/experimental and login with your Factorio account. You can pick any version of the game you like, but will probably want the latest experimental build if you're developing a mod.

Step 2: Set up a new folder to hold your game

You now need to create a new folder to place the game you just downloaded into. You can do this anywhere you choose, but to keep it simple I put the new folder in my Applications folder and call it Factorio. Now simply open the dmg from step 1 and copy factorio.app into your new folder, so in this example the path is /Applications/Factorio/factorio.app. Note that you need to create a sub-folder, and not simply drag the factorio.app into Applications like you would with other apps. You'll understand why in the next step.

Step 3: Create a custom config file

In your /Applications/Factorio folder, create a sub-folder config. Then create a new text file config.ini inside this folder. You can use whatever plaintext editor you prefer for this, just be aware that if you're using macOS's TextEdit.app, you'll need to select Format > Make Plain Text before saving. Alternatively, you can copy the config.ini file from the Steam version of the game. This file can be found at ~/Library/Application Support/factorio/config/config.ini.

Now open your new /Applications/Factorio/config/config.ini file and at the top of the file, add the following text:

[path]
read-data=__PATH__executable__/../data
write-data=/Applications/Factorio

If you copied the Steam config, you can just adjust the path section of the file to match. Be sure to set write-data to the folder you created in step 2 if you aren't using the same folder as this example.

Step 4: Deal with GateKeeper

By default, macOS prevents apps from unidentified developers from running by using a system feature called GateKeeper. Unfortunately the developers of Factorio don't digitally sign their releases on macOS and so the first time you try to run your new copy of the game, you'll most likely see this warning dialog:

Before we can continue, we need to tell GateKeeper to allow this app to run. In previous versions of macOS you could set a system preference to allow apps from unidentified developers, but in macOS Mojave, this is no longer an option (although you can disable the feature entirely, but I won't go into detail about that here).

For now, simply try running your copy of factorio.app. If it starts, great, you might have already disabled GateKeeper. However, if you get a dialog similar to the one above, you'll need to go to System Preferences > Security & Privacy > General tab and at the bottom of that panel, select the Open Anyway button.

You should now see the Factorio launching screen. Once you reach the Main Menu, select Exit to quit the game. Although the game is now able to run, this version is still using the shared game files from your Application Support folder, so it won't be able to run alongside the Steam version. That's the next part.

Step 5: Get Factorio to use your new config file

Factorio offers a bunch of helpful command line parameters to change game settings at runtime. The one we're interested in is the -c PATH argument, which will allow us to specify a custom config file. On Windows these arguments are easy to specify, however on macOS it's not so simple. To send a command line argument to a Mac app, you need to open the Terminal and run the following command:

open -a /Applications/Factorio/factorio.app --args -c /Applications/Factorio/config/config.ini

This command will tell the system to open Factorio from our standalone folder and use the custom config file we created above. If you're happy running the game like this, you can do just that but note that you can't just double click the factorio.app in the Finder as this will use the default config and will not allow you to run two copies at once.

If you don't want to have to run the Terminal command every time you launch the game, you will probably find it more helpful if you could just double click on your own app. Enter Automator!

We'll quickly create a small app launcher that will pass the command line arguments to Factorio for us. Go to your Applications folder and launch the Automator app. Select New Document and when asked which type of document to create, select Application.

On the far left side of the Automator window, select Utilities from the Library and then in the next column double click on the Run Shell Script action. This will add the action to the workflow on the right of the window. At the top of this action, make sure the Shell dropdown is set to /bin/bash and then paste the Terminal command above into the action body. Your action should now look like this:

Now all you need to do is select File > Save... and save this application to your /Applications/Factorio/ folder. Give it a useful name like Launcher.app so you can remember what it does.

Finally, all that's left is to run the game! Go to the Finder and double click on your new Launcher.app. You should see the main Factorio window appear. If everything worked correctly you should also see the game has created all it's configuration and log files in your custom Factorio directory. It should look something like this:

With this copy running, you can now go to Steam and launch the Steam version of Factorio. It will launch alongside your standalone copy and use it's own configuration files. You'll now be able to launch a multiplayer game in one copy and join it from the other.

I hope you found this tutorial helpful. If you have any questions, leave a comment below, or you can occasionally find me on the Factorio Discord.