Use Grunt



  •  

    I am trying to create a folder on my PC to mirror my screeps scripts. I am an experienced C++ programmer with no javascript.

     

    First off is there some way to export my scripts from the loader, I am thinking of something like <export as zip> giving a zip file containing stuff like main.js, role.builder.js etc.

     

    Second I could not make sense of the “committing scrpts using direct API access” article, not noddy enough for me.

     

    Third I tried following “Committing local scripts using Grunt. I had some problems. Using Windows 10.

     

    There was no mention of how to create the package.JSON file. So I used npm init, is that ok?

    When I run npm install grunt-screeps I got the following warnings should I be worried. I don't want to spend ages installing and upgrading a lot of unnecessary programmes.

     

    C:\Users\Piers\Documents\My Games\screeps\dist>npm install grunt-screeps

    npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

    npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

    npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.

    npm WARN deprecated minimatch@0.4.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

    npm WARN deprecated lodash@2.4.1: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.

    dist@1.0.0 C:\Users\Piers\Documents\My Games\screeps\dist

    +-- graceful-fs@4.1.4

    `-- grunt-screeps@1.2.1 extraneous

     

    npm WARN grunt-contrib-clean@0.5.0 requires a peer of grunt@~0.4.0 but none was installed.

    npm WARN grunt-contrib-jshint@0.9.2 requires a peer of grunt@~0.4.0 but none was installed.

    npm WARN grunt-contrib-nodeunit@0.3.3 requires a peer of grunt@~0.4.0 but none was installed.

     

    When I run grunt screeps I get

     

    C:\Users\Piers\Documents\My Games\screeps\dist>grunt screeps

    Running "screeps:dist" (screeps) task

    Fatal error: Screeps server returned error code 401

     

    What is the likely reason for this? Could it be a Steam thing where I need something special for email and password?

     



  • If you are using the steam version of the game, you already have the scripts somewhere on your harddrive, though I don't know where exactly. If you are using the web version, you should check the recent posts, because a few weeks back someone posted a script to easily download scripts from the server. last option is to copypaste each file manually.

    as for commiting scripts to the server, I think most of us who work with local code are using the grunt way. 

    "npm init" should be the correct way, yes. the warnings aren't really for you, they are for whoever included the mentioned packages in their package; I'm guessing whoever wrote grunt-screeps. You can just ignore those.

    "error code 401" looks like a http status code, 401 would be "Unauthorized". You will need to set your login information somewhere (I think in Gruntfile.js). This is your screeps login information, NOT your steam login information. Then it should work, upload whatever .js files you currently have to the server and replace whatever is on there right now. So make sure you have your latest scripts in the project before you run "grunt screeps".



  • Thanks for your help.

     

    I found copies of the .js files at C:\Users\<UserName>\AppData\Local\Screeps\scripts\screeps.com\default

    So that's great.

     

    It seemed that I had not set a password. After I set a password from Managed account in the Steam window the “grunt screeps” command worked.

     

    So next question what is the thing about linking your Github account. I see “logging on with your GitHub account” option given in various places, but I cannot find an explanation about this feature.

     



  • When you link your account, one benefit is, as you've already seen, the login via github, which is just convinience. However, you can also set it up in your account settings to let screeps automatically pull changes from a github repo. 

    Since you are using grunt to upload changes now, which imho is the superior solution, that's probably not really a concern : )