Well, module.exports
is actually not a pure JavaScript, but rather node.js feature. You can read more on what it is and how it's used here. But in general, assign to it the thing (or object of things) you want your module to export. Nothing else will make it out, which is kinda useful to isolate some globals in the module itself. And once you put var moduleSomething = require(your.module);
somewhere else, that variable will become the object you assigned to module.exports
in your.module
module.
So, basically, require
fetches the object (or whatever else you have) that is assigned to module.export
in your module file.
Unfortunately that's about as much as I can help you with your quest, since I've only been playing Screeps like 3 days so far, and not overly familiar with anything outside of my own room. But hey, at least my creep population is thriving.
What I did was :
Install Node v6 (somehow more stable than latest versions for screeps) from source : https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-armv6l.tar.xz (look for a tutorial on your favorite search engine) It should be as easy as copying files to /usr/ (here is my history for example :
34 cd node-v6.11.0-linux-armv7l
35 cp -R bin/ /usr/
36 cp -R lib/ /usr/
37 cp -R share/ /usr/
38 cp -R include/ /usr/ )
now install screeps with : npm install -g --unsafe-perm screeps (needed --unsafe-perm to be able to build after the download)
Then everything worked, I just claimed my steam API, copy pasted running : screeps init
then : screeps start
and setup was done.
Hope this helps
Finding the perfect IDE is a pain when looking for something very specific...
But nowadays I'm pretty happy when things are getting done...
For now I'm using atom, and since it's open source I shouldn't care anymore about weird things that the ide is doing... See https://atom.io/
This did not work for me. However, it prompted me to attempt to find the solution to this problem again, as the lack of intellisense is rather frustrating.
VS Code uses TypeScript type declarations for JavaScript intellisense (https://code.visualstudio.com/docs/languages/javascript#_intellisense). I had already tried using these files before, to no avail. But it turns out that adding typings to my project was all that was necessary.
Download the latest release zip of this: https://github.com/screepers/Screeps-Typescript-Declarations/releases
Unzip the archive and copy the screeps.d.ts file from the dist folder into a folder within your project (doesn't have to reside in the same folder as your source, as long as it's within the project's folder).
Install typings (add it to your project.json or install globally, however you choose).
You should now hopefully have intellisense for the Screeps API with type information, etc.
Here's a really bloated version that I wrote a while back. Honestly, I got really into screeps for about a month, and then I got tied up in some other thing, so I'm not entirely sure what I was doing here. I think it was looking for a structure, not a controller, but the logic is still there.
Anyway, I like to put the little guys in "modes" using a "status" variable in memory. A harvester, in this method, is either trying to fill up or trying to empty out. Once it completes one of those tasks, it switches to the next mode. I hope this helps you a little.
Do you need a domain name? I can't quite remember how to set things up, but I know that I set things up using my own domain.
If you need a domain, google domains is a cheap option. DON'T USE GODADDY - they're nothing but trouble.
The steps are at
http://screeps.com/g/components/game/tutorial/step1.html
through
http://screeps.com/g/components/game/tutorial/step29.html
You'll have to view the page source to see the sample code they provided, like on step 7.
Yep, the simulation rooms are limited to 5 seconds of script execution.
From http://screeps.com/docs/coding.php
> Please remember that the exact duration of the execution of your script is limited by the CPU time available in your service plan. In case of exceeding the limit, the script execution will be stopped. The exception is the Simulation Room where the script execution is always limited by 5 seconds.
If you haven't installed node yet, do so: https://nodejs.org/en/download/
Although you don't really need it, because all the code is running on the screeps servers, not your own. It'll still help with debugging though.
I taught a lot of people too (http://tutsplus.com/authors/maciej-sopylo).
Learning how to program in general requires a lot of dedication. Programming is dedication and clever thinking. My friend who never touched JS and has little to no experience in programming created a self-sustaining colony in less than a week. I left him with documentation and a few tips here and there when he hit the classic JS issues (https://www.destroyallsoftware.com/talks/wat <3).
Idk, maybe he is very talented. Maybe he's just very dedicated. I learned programming to create games. When I started it was BASIC - it sucked. I switched to C++ - it sucked even more. C was ok, but I liked Pascal more. Now there is a gazillion of easy scripting languages to choose from, JS being one of the simplest (I had fucking Lisp, good luck grasping that as a beginner :D).
I don't want to criticize, but your videos are on average 25 minutes long. Eight videos is around 3.5h. That's enough to go through half of Crockford's book (JavaScript: The Good Parts). You read the whole thing, maybe a few times, grab the docs and you have all you need to code for Screeps.