syntax error from the screeps console
Opened this issue · 4 comments
SHADOWELITE7 commented
so I was starting out your nooby guide part 2. When I ran the code I kept getting this in the console.
[6:31:02 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:05 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:08 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:11 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:14 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
I don't know if its my code that I used from your tutorial so I will copy the code and put it here.
module.exports.loop = function () {
var creep = Game.creeps.Alaina;
if (creep.memory.working == true, &&_creep.carry.energy == 0) {
creep.memory.working = false;
}
else (creep.memory.working == false && creep.carry.energy == creep.carryCapacity) {
creep.memory.working = true;
}
if (creep.memory.working == true) {
if (creep.transfer(Game.spawns.Spawn1, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(Game.spawns.Spawn1);
}
}
else {
var source = creep.pos.findClosesetByPath (FIND_SOURCES);
if (creep.harvest(source) == ERR_NOT_IN_RANGE) {
creep.moveTo(source);
}
}
}
I do think its probably these &&
in the code.
I use sublime text 3
version 3.2.1
build 3207
SHADOWELITE7 commented
I additionally got this from an email
TypeError: creep.pos.findClosesetByPath is not a function
at Object.module.exports.loop (main:10:13)
at __mainLoop:1:52
at __mainLoop:2:3
at Object.exports.evalCode (<runtime>:15990:76)
at Object.exports.run (<runtime>:30481:24)
Tim-Pohlmann commented
you got a typo in line 4:
&&_creep
remove the _
SHADOWELITE7 commented
when I have time to test it out on screeps. I will comment and close this issue. If I have more issues I will keep it open
davv1 commented
@SHADOWELITE7 There's nothing to test - it's literally one single sign typo which thPion already mentioned, so you can close it freely.