Thanks guys. I did get it to work by following your corrections Chris. I also figured out that putting ; after a bracket will return errors. Thanks for helping guys
Draoi
@Draoi
Posts made by Draoi
-
RE: Unexpected token {
-
Unexpected token {
Could someone help me? This was all I edited so it should be within here, but I keep getting unexpected token { errors.
if (4 < harvesters < 6){ if (guards < 4){ Game.spawns.Spawn1.createCreep(guard, null, {role: "guard"}) elseif(medics <3){ Game.spawns.Spawn1.createCreep(medic, null, {role: "medic"}) elseif (builders < 3){ Game.spawns.Spawn1.createCreep(builder, null, {role: "builder"}) elseif (harvesters < 16){ Game.spawns.Spawn1.createCreep(bodyExtractor, null, {role: "harvester"}) }; }; }; }; };
Also, if there is a better way to do what I am trying to do (As in, build these first, then these, then these after we have enough of each etc), then please tell me. But my purpose here is to solve the error.
-
Email notifications about game errors
I keep getting email notifications about a supposed error going on in my game world, but I'm not in the main Game yet (i did apply but got no return email yet). I was playing survival earlier, but I shouldn't be getting email notifications from that.
-
if (''role' > 6)
if (harvesters < 6){ Game.spawns.Spawn1.createCreep(bodyExtractor, null, {role: "harvester"}) }; if (harvester >= 2){ if (guards < 4){ Game.spawns.Spawn1.createCreep(guard, null, {role: "guard"}) }; if (builders < 3){ Game.spawns.Spawn1.createCreep(builder, null, {role: "builder"}) }; if (medics < 2){ Game.spawns.Spawn1.createCreep(medic, null, {role: "medic"}) }; };
So far it gets up to exactly 2 harvesters, but then stops making anything at all despite having plenty of energy. My idea is that it should produce harvesters, after it reaches at least two then it could build guards as well (this is for the survival mode). It just doesn't build anything after 2 harvesters.
-
RE: Get number of creeps with "x" role
Oh dear. I actually, even after copy/pasting it into here, failed to realize i left role: 'x' in there. Meant to change that to harvesters. Thanks for your help, it finally works. I checked the memory, I had over 202 creeps spawn since I started it, which was hours ago and even running on 500% speed, it was still taking between 5-10 seconds per tick. There were easily over 100 creeps on screen. SO. MANY. HARVESTERS.
-
RE: Get number of creeps with "x" role
Thanks JMC, but I'm not really sure I understand what you observed in the other post relates here. I'm still pretty new to coding so it might just be my own problem, but did I mis-order my code that caused a problem? Please elaborate if you can.
My main goal here is to compare the number of creeps in existence with a specified role (ex: 'harvester') to a constant or variable, in this case the constant 5. My idea for the code was that once that many creeps exist, then it would stop producing more, so I don't overflow with almost a hundred harvester creeps (I currently am doing that in another tab in the custom game section). How could I amend (or really, if need be rewrite) my code to heed the limit I place?
-
RE: Get number of creeps with "x" role
Thanks for the help, guys. My current problem is this:
var harvesters = _(Game.creeps).filter( { memory: { role: 'x' } } ).size(); if (harvesters < 5){ Game.spawns.Spawn1.createCreep(harv, null, {role: "harvester", set: "extractor"}) };
I'm trying to tell the game to stop producing harvesters after we have 5 out. I'll expand that later to depend on my energy situation, but this is currently for testing. As it is it completely ignores what I said and my spawn is producing a 6th harvester. How can I fix that?
-
Get number of creeps with "x" role
I'm new to Javascript especially though I have a little experience in other languages like C#.
I'm trying to figure out how to call from the memory the number of creeps with a specific role so I can use that in my script. Sorry if it doesn't make sense, I'm trying to phrase it the best I can.