I have much to learn, but I know I don't know a lot, so I will start there.
I thought it was about time to learn to play this game that I have had on my to do list for a while. Here I will leave notes to myself that helped me with my learning.
I went the route of using VSCode
and Github
which involved several things:
Once you have created a Github account and created a repository for your screeps code and done a first commit (usually a quick markdown file) you will want to link it to your screeps account:
- Go to the Screeps website and sign in as yourself. If you bought it via steam you will likely need to sign in that way.
- Click your avatar in the top right corner and select
Manage Account
. - At the bottom you will find the
Github
section where you can link your screeps account to your repository. ClickGithub user
to sign in, then clickSync from repository
to select your newly made repository to connect to. Note you can choose to use a specific folder in that repository, but if you wish to use the root then leave the folder blank.
To use VSCode
you will want to set up your files to work with your git repository, and have JavaScript auto-complete for the screeps game.
The following steps assume that you have already installed VSCode
.
There are several ways of doing this based on your current situation.
To work with Git
you will need to have it installed on your computer already. If you don't you can find it here.
As mentioned above, these instructions assume you already have a Github
account.
I recommend doing it this way as it will involve less steps.
Because you should have already created your repository in Github, you will be wanting to pull requesting
or cloning
it to your local machine into the directory of your choice:
You can also watch this video of the process.
- Decide and create on your PC the directory that will contain your screeps code.
- Check your settings have Git enabled checked by going to
File > Preferences > Settings (Ctrl+,)
then typeGit: enabled
and make sure that the option is checked. - On your Github page you will want to open the repository you created for screeps and click the
Clone or download
button and copy the URL, or simply copy the URL from your browser's address bar. - Go to the
Source Control
tab click on clone repository or go to yourCommand Palette
withView > Command Palette...
and type/selectGit: Clone
. - Within the
Command Palette
add your repository's URL. - You will be asked to select a folder, choose the directory you have made for your screeps code, or make create it at this point if you haven't already.
You will now have your repository (with only a readme file) pulled
to that directory and opened in your VSCode
.
This one takes a couple more steps, and is the way I went, so hopefully this helps others new to it like myself not have problems:
You can also watch this video of the process for the most part, it simply lacks the step of merging the repository content and your current code as they won't match.
- Open the screeps code directory in
VSCode
by going toFile > Open Folder
and then selecting the root folder for your code. This will open your files in theExplorer
tab ofVSCode
. You can also do this by being in theExplorer
tab and simply dragging and dropping the folder into theExplorer
column. - Go to the
Source Control
tab and clickInitialise Repository
or go to yourCommand Palette
withView > Command Palette...
and type/selectGit: Initialize Repository
. - Select the folder from the
Command Palette
the correct folder name that matches your code's directory (that you added previously). - In the
Source Control
tab you will see that all your code files have aU
next to them, this means they areuntracked
at this time. You will need to write a comment in theMessage
field and then click the check mark tocommit
it. - Add your
Github
repository by going back to yourCommand Palette
and typing/selectingGit: Add Remote
. - Within the
Command Palette
give it a name, its recommended to have the same name as yourGithub
repo. - You will be asked to provide the URL of the repository within the
Command Palette
, you can obtain this by going to your Github page, opening your screeps repository click either clicking theClone or download
button to copy the URL, or simply copying the URL from your browser's address bar. paste this into theCommand Palette
and press enter. - Before you can
push
thiscommit
however, you will need topull
your already initialised repository and this will require allowing the unrelated histories (of theGithub
repository and your directory) to come together. Open yourTerminal
by going toView > Terminal (Ctrl+,)
. - First we will need to specify tracking information for your current
commit
, in theTerminal
use the command:git branch --set-upstream-to=<name of your Github repository>/master master
, just replace<name of your Github repository>
with the actual name you gave your repo. - Next we will pull the unrelated histories together using the command
git pull --allow-unrelated-histories
. - Now we can
push
thecommit
by clicking the...
button inSource Control
and selectingPush
.
Now your directory and Github
repository will match and have all the files.
If you have already got code in you directory and have already initiated your Git repository then you can create a repository and connect it to your directory by simply doing:
You can also watch this video of the process.
- Open the screeps code directory in
VSCode
by going toFile > Open Folder
and then selecting the root folder for your code. This will open your files in theExplorer
tab ofVSCode
. You can also do this by being in theExplorer
tab and simply dragging and dropping the folder into theExplorer
column. - Go to the
Source Control
tab and clickInitialize Repository
or go to yourCommand Palette
withView > Command Palette...
and type/selectGit: Initialize Repository
. - Select the folder from the
Command Palette
the correct folder name that matches your code's directory (that you added previously). - In the
Source Control
tab you will see that all your code files have aU
next to them, this means they areuntracked
at this time. You will need to write a comment in theMessage
field and then click the check mark in the top right tocommit
it. - Go to your
Github
page to create your new screeps repository by clickingNew
on your repositories page. - Give it a
Name
, and choose whether it is public or private. Optionally add a description. Do NOT initialize the repository at this stage, if you do, follow from step 4 in the If You Have Made and Initialised a Repository With Files And Have Code section. - Click
Create Repository
and from the web page copy the URL showing in theQuick setup
box, or just copy the URL from your browser's address bar. - Now add your
Github
repository toVSCode
by going back to yourCommand Palette
and typing/selectingGit: Add Remote
. - Within the
Command Palette
give it a name, its recommended to have the same name as yourGithub
repo. - Now paste the URL of your repository within the
Command Palette
. - You can now
push
yourcommit
from theSource Control
tab by pressing the...
button and selectingPush
.
You are now ready to send your code to Github, and this will then be added to your screeps.
The method I used was described in this video.
However, there is also this set of instructions to install it using the Garethp/ScreepsAutocomplete repo.
I will detail the first method:
- Install
Node.js
by downloading it from this link. - Make sure that the
Add to PATH environment variable
is enabled during the install as this is required for the next steps to work. - Open the
Terminal
inVSCode
by going toView > Terminal (Ctrl+')
. NOTE: you may have to runVSCode
inAdministrator mode
for this to work if you get error messages. - Type the command
npm
in the terminal to make sureNode.js
has been added to PATH (you should see a list of helpful messages appear if it is installed). if it isn't you will have to go and add it to your PATH. - Type the following 2 commands
npm install @types/screeps
npm install @types/lodash
Once done you should be able to see these API commands suggest autocomplete options while typing your JavaScript
code.