1 js file per module; require does have an overhead though, so I'd just concatenate all files into one big main.js file on build
nugarin
@nugarin
Posts made by nugarin
-
RE: Creating a screeps github repository
-
RE: creep.memory.role
var creeps = _(Game.creeps).filter({
memory: {
room: spawn.room.name
}
I am pretty sure that this already gives you a list of Creep objects, not their names -
RE: Unexpected token {
I'd also restructure it, it is too WET right now, you want your code DRY
One might argue that Game.spawns.Spawn1.createCreep is only one line, but this is a function call, that you WILL change as your screeps empire grows, you'll heave more than one spawn, createCreep may not succeed and you'd want to fall back to another one. So I'd split this loop to two logical sections
1)Pick creep
2)Create creepCode becomes:
```javascript
//Select what to build
var creepBody = null;
var creepMemory = null;
if (guards < 4){
creepBody = guard;
creepMemory = {role:"guard"}
}else if (medics < 3){
creepBody = medic;
creepMemory = {role:"medic"}
}
...
//Build
Game.spawns.Spawn1.createCreep(creepBody, null, creepMemory); //easy to replace the createCreep call, fall back when it fails, etc.//Now, let's get more javascriptey:)
var creepSetupsByRole = {
"guard" : {
"min": 4,
"body": [ATTACK, ATTACK, MOVE],
"max": 10,
"curr": 0,
"roleName" : 'guard',
"essential" : true //Do not try to build others unless have enough of this role
},
"medic" : {
"min": 4,
"body": [HEAL, HEAL, MOVE],
"max": 10,
"curr": 0,
"roleName" : 'medic'
};
//Count the current number of creeps with given role here.
//Possibly sort roles by prioritiesfor (var roleName in creepSetupsByRole){
var currRoleSetup = creepSetupsByRole[roleName];
if (currRoleSetup.curr < currRoleSetup.min){
var buildResult = tryBuildCreep(currRoleSetup);
if (!(buildResult < 0) && !currRoleSetup.essential){ //
break;
}
}
}function tryBuildCreep(creepSetup){
return Game.spawns.Spawn1.createCreep(creepSetup.body, null, {role: creepSetup.roleName});
} -
RE: Allow placing the first spawn programmatically
That would require programmatic access to all the rooms as well. Currently you have programmatic access to rooms that have your structures or creeps in it.
You could write a GreaseMonkey userscript to achieve what you want - however, I am not sure, how will you be able to define the "best room" to that script, since there are more considerations than just amount of available energy sources, absence or existence of Source Keepers, etc. You might start in the perfect room, then find out that all its neighbours are totally useless, or spawn in a position that is blocked by other players, giving you no room for expansion. -
RFC CEMENT
I just had a brainfart - we need to write and RFC for screep-based messaging system and submit to the IETF. Look at RFC 2549 for inspiration.
Basic idea is that, energy-carrying creeps are used to carry messages - creep energy level is used to carry the message header and content.
There could be variations of messages - simple ones with one-to-one energy-level to ASCII code conversion and complex ones with compressed data. Packet order could be determined by the screep movement vectors or could be a part of the energy level.We also need a catchy name for the messaging protocol - please submit yours in the comments below. Current working title is Creep Encoded Messaging Energy Network Transport.
I'll start:
A standard for the Transmission of textual information on creeps.
Status of this Memo
This memo defines an Experimental Protocol for the Screeps
community.
Discussion and suggestions for improvement are requested.
Distribution of this memo is unlimited.Abstract
This memo defines a way for sending and receiving messages between overlords of the creeps in the game Screeps.
Description
... -
RE: Exploit?
-- That's not fun and impossible to defend against!
Puh-leease - 1) your defenses should have already been in place 2) Defending against RCL 1 with RCL 2+ is a no-brainer. -
RE: Dear GrandonBroseph
One could technically send creeps to the room of the message recipient and have them form letters and words, in the manner of the dear leader displays in the democratic people's republics:p
-
RE: CPU volatility
I think it also accounts for the creeps on the way. So if you are running it with default settings, it would try to path around these creeps.
opts (optional) object
An object containing additonal pathfinding flags:
ignoreCreeps boolean
Treat squares with creeps as walkable. Can be useful with too many moving creeps around or in some other cases. The default value is false. -
RE: List of keybindings for ingame editor
Ty @GrandonBroseph - it's very helpful, I edit code in Visual Studio, but sometimes one just has to put on the Cowboy hat and dig into the runtime script.
These binding should be listed in the Screeps knowledge base or there should be a link/popup from the editor.