Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error from the screeps console #13

Open
SHADOWELITE7 opened this issue May 2, 2019 · 4 comments
Open

syntax error from the screeps console #13

SHADOWELITE7 opened this issue May 2, 2019 · 4 comments

Comments

@SHADOWELITE7
Copy link

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
Copy link
Author

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
Copy link
Owner

you got a typo in line 4:
&&_creep
remove the _

@SHADOWELITE7
Copy link
Author

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
Copy link
Contributor

davv1 commented Oct 15, 2021

@SHADOWELITE7 There's nothing to test - it's literally one single sign typo which thPion already mentioned, so you can close it freely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants