GUI vs API: Placing Flags



  • The GUI allows to place flags in rooms we have no vision in - which is good and needed. 

    However, doing the same via the API is not possible, since it requires the Room or RoomPosition Object, neither of which are available without vision. You can ofc create a RoomPosition Object yourself, but even then createFlag on it gives an error:

    Error: Could not access room ...

    I'd like to suggest either changing that, or adding this:

    Game.createFlag(x, y, roomName, [name], [color], [secondaryColor])


  • oh, also: could we get another parameter for memory in the createFlag methods, like when creating creeps? That'd be neat.



  • I agree, that creating a flag being bound to the `Room` is not very nice/intuitive. I'd prefer a constructor `new Flag(RoomPosition,...)` or as you proposed Game.createFlag.

    Also, I dislike/find it confusing that using the UI does not seem to use the Prototype methods as you define them.

    To further explain, I use the following code (simplified for demonstation purposes):

    _.assign(Room.prototype,{
        _createFlag:Room.prototype.createFlag,
        createFlag:my_createFlag
    }

    function my_createFlag(...args){
    console.log('calling modified flag creation');
    return _createFlag(...args);
    }

    This works fine from within the code, but not when using the UI. (Sadly, the same is true for all other UI functions, like destroy, suicide or moving flags).



  • As a workaround, it is possible to create a flag in a room you can see, and then (on the next tick) use setPosition to place it into any room.