Code that works in game give error in simulation



  • Just a basic for loop. Works fine in game but gives an error in the simulation.

    Code:
    `for(var name in Game.creeps) { var creep = Game.creeps[name]; }

    Error:
    'SyntaxError: Unexpected token for
    ` at Object.c.runCode:5:34191



  • Messed up the formatting and can't edit. Should be:

    Code:

    for(var name in Game.creeps) { var creep = Game.creeps[name]; }

    Error:

    SyntaxError: Unexpected token for
    at Object.c.runCode:5:34191



  • Its saying 'for' is unexpected at that point in the code. Meaning whatever you have just BEFORE that point is likely the error



  • I'm running this in the console not in game. I meant to specify that in my post but it looks like I forgot that part.



  • When you run complex code in the console put it in {...} brackets.