Questions tagged [screeps]

Screeps is a JavaScript based, programmable web browser MMO RTS.

Screeps is a JavaScript based, programmable web browser massively multiplayer online real-time strategy game.

139 questions
15
votes
2 answers

How do I create a new structure in Screeps

So, this is a question about the game screeps. I know that in the simulation, I can create a road by going to the Construct menu on the left, but is there an API reference I can use to create one programmatically? My goal is to have a script that…
Gareth Parker
  • 5,012
  • 2
  • 18
  • 42
14
votes
6 answers

Screeps: calculate build cost of body

When playing the game screeps.com I want to calculate the cost of building the required body. See my attempt below, where cfg.body is the bodypart array, e.g. [Game.ATTACK, Game.MOVE, Game.WORK, Game.CARRY, Game.MOVE]: var buildCost = 0; for(var…
Anima-t3d
  • 3,431
  • 6
  • 38
  • 56
14
votes
1 answer

How do I attack an enemy in Screeps

While playing screeps I can't figure out how to attack an enemy. Here's what I tried. I created my attacker creep: Game.spawns.Spawn1.createCreep(['attack','move'],'Attacker1'); Then when the first enemy came on the screen I tried running this…
parkour86
  • 193
  • 1
  • 7
10
votes
3 answers

In Screeps, is CPU limit enforced in a way that allows CPU limit robust code to be written?

In Screeps, each player's usage of CPU is limited, but the documentation for this feature doesn't make the way this is enforced sufficiently clear for writing CPU limit robust code. I've considered the following four possibilities: 1. The player's…
TheBeardyMan
  • 829
  • 10
  • 28
9
votes
2 answers

Is there a way to delete creeps?

Is it possible to delete created creeps? Either through a script or through the GUI? I could not easily find a way to do this, but it seems like a simple functionality so I imagine it exists, or someone has thought about it or something.
tscizzle
  • 11,191
  • 15
  • 54
  • 88
9
votes
1 answer

Screeps: store reference to source in creeps memory?

Fascinating game! Looking for an example of how to persist a reference to a particular energy source in a creep's memory. Seems that storing the actual source object won't work(?).
bitbutter
  • 580
  • 5
  • 15
8
votes
1 answer

Extend Source prototype to have a memory object

I want to store some information about energy sources that I am harvesting. Ideally I would use mySource.memory.taken but Source does not have a memory property. I could implement something like this: Source.prototype.memory = function() { …
Brendan W
  • 83
  • 5
8
votes
2 answers

findNearest, findInRange - How to use in Screeps?

I try to use findNearest like that: var sources = creep.room.findNearest(Game.SOURCES) creep.moveTo(sources[0]); creep.harvest(sources[0]); and this is what i get: TypeError: undefined is not a function at module.exports:5:28 at
:11:6 How…
Krokiet
  • 131
  • 1
  • 10
7
votes
3 answers

Screeps get all creeps with specific memory (role)

I'm trying to figure out how to get every creep with a specific memory or role like harvester in a variable... I can't seem to figure it out. I already tried: module.exports = function(){ for(var i in Game.creeps){ if(i.memory ==…
Axenth
  • 73
  • 2
  • 6
6
votes
2 answers

How to extend the creep class in screeps

I am having a hard time trying to figure out how to extend the creep class to add my own functions in the new javascript mmo game, Screeps -> www.screeps.com
Ryan
  • 791
  • 16
  • 31
6
votes
4 answers

Screeps: write debug output to console?

Is there a way of getting screeps code to print strings to the console (or anywhere really) for simple debugging purposes?
bitbutter
  • 580
  • 5
  • 15
5
votes
1 answer

Screeps: How do I set up source map using TypeScript and Webpack?

I'm trying to set my new Screeps (the game) project from scratch using TypeScript (^2.9.2) and Webpack (^4.12.1). How do I properly set up source maps? What I did: Set "sourceMap": true, in tsconfig.json Set devtool: 'inline-source-map', in…
kamyl
  • 5,938
  • 4
  • 23
  • 29
5
votes
5 answers

How to generate a random name with a preceding nametag in Screeps?

In the Programming Game Screeps I spawn creeps by using: if(transporters.length < 0 && harvesters.length > 2) { var newName = Game.spawns['SpawnZone'].createCreep([WORK,CARRY,MOVE], undefined, {role: 'transporter'}); console.log('Spawning new…
user3220962
  • 371
  • 1
  • 7
  • 19
5
votes
1 answer

How to implement inheritance in Screeps objects?

I've been toying around with Screeps for a while now and last night I decided to work out some of my behaviors into a class hierarchy by deriving two classes, Miner and Transporter from a Creep main class. However, whenever I do…
Toolmaker
  • 554
  • 6
  • 22
5
votes
5 answers

Interact with Scripts from Console

Is there any way to call a module or function from the console? For example a module that creates worker creeps, called from the console with my_module.add_creep?
Ben
  • 53
  • 1
  • 3
1
2 3
9 10