New feature: code branches

One of the most often related inconveniences with the game and the editor has been the lack of various debugging tools. We plan to release the Screeps game engine as a standalone npm package so that everyone could launch a game sim locally in a console and thus perform any debugging needed, from unit testing of separate modules to modelling parallel development of game worlds with different settings. However, these are just mid-term plans, while in the short-term we plan to launch two important updates which will greatly simplify development:

  1. Branching of your scripts in a way that you can edit your code in the Simulation without affecting the code from the World, and then commit it to the World after the debugging.
  2. Better Custom Mode: import/export to JSON, saving game situation from any individual room in a game, repeating one tick in a loop, API for creating game objects in Custom Mode.

The second option will be introduced later, but we are happy to announce the first one right now!

In the scripts editor you can see a current branch selection list. One default branch is available initially. The clone function allows you to create a new branch based on it. All code from all the modules belongs to the branch cooperatively, you cannot take individual modules into a separate branch and use them from another branch.

The branch being edited at the moment is the one active in the game. However, the World may have one active branch, the Simulation another one. For example, you may clone the default branch and call the newly-created one, say, develop, then select it as active in the sim mode, and freely edit your code in it without fear of breaking something in the World game process while developing. After you are fully satisfied with the develop branch changes, you can again clone it under default name, thus replacing the basic branch and taking your changes into effect in the actual game.

If you use grunt-screeps for commiting your scripts from a local machine, you will have to update the package to have the ability to specify a branch to commit.

We hope this update will simplify testing and debugging of your game scripts.

Have more questions? Submit a request


  • utiutiuti

    Really nice to see the progress. Keep up the good work. Greetings from Germany.

  • Portpoise

    Awesome! This is a very nice addition!

    For those who might be wondering -I did check - and the corresponding API documentation HAS been updated as well... ;)

  • The_General

    Awesome! I've updated my local git push script to take advantage of this. I definitely notice a speedup while pushing changes because it doesn't have to upload 2 copies of my code anymore :)

    A quick note: If you use /api/user/code to update a branch that doesn't exist you will get 200 OK but nothing happens. You have to first create the branch using the in-game editor, then you can update that branch via the API.

  • Hawthorn

    Any chance that you could hook this up to the github synch? Right now I synch in just fine from master .. but branches on git are not synching?

  • XyzzyPrime

    This feature should probably be called Code Folders instead of Branches. It is NOT a branch in the Git meaning.

    I have a git repo that has many branches. When I check one out into the working folder on local, then grunt that set of code to the Screeps Server, it replaces whatever is in the "Branch" on the server with all of the code in my local folder.

    I have different folders on my local drive and there is a different gruntfile.js in each that points to the Server "Branch" from that folder of code.

    So from my local Drive pushed to ("->") Server Branch.

    F:\Project\screepscode\test1 -> test1

    F:\Project\screepscode\MainAI -> MainAI

    F:\Project\screepscode\MyBestOne -> MBO

    Each folder has a gruntfile.js with a corresponding line like:

    • branch: 'MainAI',
    Edited by XyzzyPrime
Powered by Zendesk