Dev Tutorial [Editor] Using version control with the OMSI Editor

snipermaster1001

New Member
Sep 20, 2018
12
Version control systems act as a time machine for your project, with a couple of clicks you can revert to an older version. We'll be using Git for this, other alternatives like SVN are available though.

Warning: If you have multiple OMSI installs, when you switch Git may freak out. Make sure to be careful with multiple installs. But you can always revert changes anyway with Git.

STEP 1: Picking your Git service

Personally, I use GitHub but it's a paid service unless you want your repository to be public, for most people GitLab should work fine. So the steps below will be for the GitLab option.

STEP 2: Making a repository


After you've signed up to GitLab click the 'New Project' button, name it what your maps OMSI folder name is called. For example 'Test-Map'. You'll probaby want to set it to private as well. Then just click 'Create project'.

STEP 3: Setting up the client

Now you need to set up the Git client that will do all the work on your machine. For this tutorial, we will use Sourcetree other alternatives are available and will have a similar process of setting up. Once you've installed SourceTree we can link our repository.

1. Click the Clone / New button.
1539510473925.png


2. Set the source path / URL to the HTTPS URL on your repository. The screenshots below will show you how to do this.

1539510773599.png

Select the HTTPS dropdown.
1539510795906.png


Copy the URL to clipboard.
1539510734156.png

Paste into the text entry.

3. Click the Destination path box and after a couple of seconds, you'll be prompted to enter your gitlab.com username and password. Fill out the username and password, they are the same as the details you made your GitLab account with.

1539510981661.png

4. When you've logged in successfully you should see the repository type change to:
1539511041745.png


5. Set the destination path to your map folder. (for example: E:\Files\steamapps\common\OMSI 2\maps\Test-Map)
Note for anyone with multiple OMSI installs, if you have multiple installs please load the install you are making your map with for this and don't use the Git client when you've got another install loaded. Remember if you do mess something up though, you can just roll back with Git.

6. IMPORTANT: Make a copy of your map then delete the map. Please make an actual copy and don't just put it into your clipboard. Make sure the folder for your map is gone.

6. Click clone, before you do make sure everything is set up like this:
THIS SCREENSHOT HAS AN ERROR THE DESTINATION PATH SHOULD BE THE MAP DIRECTORY EG: E:\Files\steamapps\common\OMSI 2\maps\Test-Map)
1539511641363.png


7. You should see this when done
1539511735091.png



STEP 4: Getting the map uploaded

1. First, let's put your map back in its folder like normal. (if you see a .git folder inside Test-Map don't delete it and ignore it.)

2. Now everything is back in the folder, go back to the client and you'll see something like this:


1539511848089.png

This looks complex but it's really simple, basically, these are all the changes compared against the repository which we just made and it's empty. We want our map in the repository so click the Stage All button. You'll notice all the files move to the top in the Staged files list, that means they are ready to be uploaded.

3. Goto the box at the bottom and describe your changes, then click the box saying 'Push changes immediately to...' and click Commit.

1539512099515.png


4. Once you've committed the files, go back to GitLab and goto your project. You should see your map.
1539512195344.png

STEP 5: The basics

Every time you save your map in the editor your git client will have some staged files, basically, you want to commit those files just like we did above everytime you do something significant or if you're about to edit terrain or something and you'd like a way to roll-back. Before you roll-back a commit CLOSE THE EDITOR.

To roll-back a commit it's simple, click the master tab under branches:
1539512459728.png


then right-click the commit you want to undo and click 'Reverse commit' or you can go back to a specific commit by right-clicking the one you want to go to and clicking 'Reset current branch to this commit'.

Once you've done either of these things you'll see something like this:
1539512578579.png


just click the push button and it'll update and sync everything with the server. Then you can go back into your map and, it's been rolled-back! This tool is super-useful for all mappers and allows OMSI to actually have an undo/redo function which is great

If you want to get back to committing (updating your map to the server) click the File Status - Working copy button.

If you need more help with Git just google your issue with git in front, Git is used by software development companies, every game developer ever and more so you can find answers online.


Hope this helps.
 

Attachments

Road-hog123

An Orange Bus
Administrator
UKDT
Dec 10, 2015
1,772
For my projects, I store the files in a project directory outside of my OMSI installs, and symlink/copy files across when I need them in an OMSI install. Take for example British Road Detailing Pack 2, which is stored in W:\Nathan\GoogleDrive\Dev\OMSI\British-Road-Detailing-Pack\. Inside that directory is the .git directory and that which you can see in the repository on GitHub. I can therefore store not just one directory but Fonts, Sceneryobjects and Splines, alongside source material. For a map project you could store not just the map but all the dependencies in source control too. SourceTree doesn't get annoyed when I switch OMSI installs either as the project directory doesn't move.

The only (rather major) issue that I've found is that the OMSI editor won't resolve symlinks when adding objects/splines. OMSI will happily follow symlinks when you load your map into the Editor or main game, but when you navigate to an object that you haven't placed before it will just refuse to add it. I imagine there's probably some software somewhere that could be used to keep two folders in sync that doesn't involve symbolic links that would resolve this.

Oh, and you'll absolutely want to set up a .gitattributes to make sure files get properly commited as text/binary and that text files are properly commited with CRLF line-endings.