dryRun option works when pasting directly in console but not when console.log()
- 
					
					
					
					
Minimum information needed:
Which shard is affected?
Simulation room
What happened?
The following code
console.log(Game.spawns['Spawn1'].spawnCreep([WORK,CARRY,MOVE], newName('harvester'), {dryRun : true})results in
0Pasting the following directly in the console creates the creep. Although the console just told me it was not possible.
Game.spawns['Spawn1'].spawnCreep([WORK,CARRY,MOVE], 'harvester008', {dryRun : false})What should have happened?
Yields 1 or true for the first line of code.
How can we reproduce this?
- Run Screeps in Simulation mode locally or on the Screeps simulation
 
Optional information:
The program should continue to
console.log 0after pasting the command manually but the console result is now-6I cannot find a pattern in this behaviour. Also the following commandconsole.log(Game.spawns['Spawn1'].spawnCreep([WORK,CARRY,MOVE],'bab', {dryRun : true} == true) )results in
-10
 - 
					
					
					
					
Please see https://docs.screeps.com/api/#Constants and the documentation for StructureSpawn.spawnCreep.
Screeps return codes are like return codes in C. 0 means success, and anything else is an error code that gives some explanation of what went wrong.
So in your first example you specified
dryRun: trueand got 0 (OK) because it was possible. So you run withdryRun: false, and it creates the creep.Then you get
-6(ERR_NOT_ENOUGH_ENERGY), because you've just used the energy to spawn the first creep and you don't have enough to spawn another one.The final example gives
-10(ERR_INVALID_ARGS), becausespawnCreep([WORK,CARRY,MOVE], 'bab', {dryRun: true} == true);is equivalant to:
spawnCreep([WORK,CARRY,MOVE], 'bab', false);...which is not valid.
 - 
					
					
					
					
@SystemParadox Thank you for pointing out the return codes. I was not familiar with those and apperantly I've overlooked those while reading the doc. As the
opts dryRunis aBooleanI was somehow also expecting the result aBoolean. Also thank you for explaining the other error codes.