Flag Bugs.



  • Hi,

    I did the tests below to see what you can do with flags. It seems like you can do only 1 intent per flag per tick, you can create, but you cannot change the colors/posistion after. The next tick you can only change color or position. Below I've added the code I tested with and the various changes I did to recreate the issues. These were done with the room Object seen, I can do additional tests with out room object.

    Test environment

    Shard2 created a flag named test - color white/white. This is the function I tested with. Moving and commenting out parts I don't need.

    function testFlagFunction() { if(Game.flags.test === undefined) return; let testFlag = Game.flags.test; var testPos = new RoomPosition(25,25,'E19S49'); var testPos2 = new RoomPosition(20,20,'E19S49'); // console.log("remove", testFlag.remove() ); console.log("setPos",testFlag.setPosition(testPos)); console.log("setColor", testFlag.setColor(COLOR_WHITE,COLOR_WHITE) ); }

    First test is just make sure all the functions work alone as intended.

    1. Remove() --- Success - Returned OK.
    2. setColor --- Success - Returned OK
      • Can move flag location manually.
      • Cannot change flag color manually.
    3. setPosistion() --- Success - Returned OK
      • Cannot change flag location - but visuals I have programmed do show up in the location I'm trying to move to.
      • Can change color Manually.

    Not having vision in the room.

    1. Remove() --- Returned OK X(random) times before it succesfuly removed, sometimes 3 ticks, sometimes 20 ticks.
    2. setColor --- Returned OK - Never changed Colors.
      • Can move flag location manually.
      • Can change flag color manually.
    3. setPosistion() --- Returned OK - Never changed Posistion.
      • Can Change Flag pos
      • Can change color Manually.

    2nd series of test will now be a combination of commands.

    1. setColor then remove()
      • Expected Behavor should be the flag is removed.
      • Both come back 0 - or OK
      • Flag color changes -
      • Flag does not get removed.
    2. SetPos then Remove()
      • Expected behavor is that the flag should be removed.
      • Both come back 0 - or Ok.
      • Flag changes pos.
      • Flag doesn't get removed.
    3. SetColor then setPosistion()
      • Expected Behavor should be change in color and posistion.
      • Both come back 0 or OK
      • Flag changes color
      • Flag does not change location.
    4. Remove() then setColor
      • Expected behavor is error code due to setColor
      • Both come back 0.
      • Remove doesn't go into effect.
      • SetColor works changing flag color.
    5. Remove() then setPosistion()
      • Expected Behavior is error code due to flag being removed.
      • Both commands come back 0
      • Remove doesn't go in effect.
      • Flag does change location.
    6. SetPosistion then SetColor()
      • Expected Behavior is that it changes color and location.
      • BOth commands come back 0
      • Setposistion does work
      • Flag color doesn't change.

    Same commands, but with out room vision/object.

    1. setColor then remove()
      • Expected Behavor should be the flag is removed.
      • Both come back 0 - or OK
      • No color change or remove done.
    2. setPos then remove()
      • Expected Behavor should be the flag is removed.
      • Both come back 0 - or OK
      • No pos change or remove done.
    3. SetColor then setPosistion()
      • Expected Behavor should be change in color and posistion.
      • Both come back 0 or OK
      • NO color or pos changes.
    4. Remove() then setColor
      • Expected behavor is error code due to setColor
      • Both come back 0.
      • No remove or SetColor
    5. Remove() then setPosistion()
      • Expected Behavior is error code due to flag being removed.
      • Both commands come back 0
      • No remove or setPos
    6. SetPosistion then SetColor()
      • Expected Behavior is that it changes color and location.
      • BOth commands come back 0
      • no pos or color change.

    CreateFlag test

    1. Testing it alone.
      • Returned 'test'
      • Flag created.
    2. Testing it with setPosistion
      • Returned 'test'
      • Returned setPosistion 0
      • Flag Created.
      • No change in posistion.
    3. Testing it with setColor.
      • Returned 'test'
      • Retuned Setcolor 0
      • Flag Created.
      • No change in color.
    4. Testing it with remove.
      • returned 'test'
      • Flag Created.
      • returned 0 for remove
    5. Flag exists, doing createFlag then setPosistion
      • Returned -3 for the flagCreation
      • setPosistion Does work and returned 0. . Flag exists, doing createFlag then setColor
      • Returned -3 for the flagCreation
      • setColor Does work and returned 0.

    Below is the function I used to test CreatFlag.

    function testFlagFunction() { var testPos = new RoomPosition(25,25,'E19S49'); var testPos2 = new RoomPosition(20,20,'E19S49'); if(Game.flags.test === undefined){ console.log('create', Game.rooms.E19S49.createFlag(25, 25, 'test') ); let testFlag = Game.flags.test; // console.log("setColor", testFlag.setColor(COLOR_YELLOW,COLOR_WHITE) ); // console.log("setPos",testFlag.setPosition(testPos2)); console.log("remove", testFlag.remove() ); }

    }


  • Dev Team

    Hey likeafox,

    Thank you for the report. The issue is queued for investigation and fixing.


  • Culture

    It gets really fun when you place a flag by hand in a room that has no active entities in it (enemy or friendly creeps). The flag gets added to your Game.flags object but you can't modify it in the code, which means if you try to change the color it fails to actually change the color even though setColor returns 0.


Log in to reply
 

Looks like your connection to Screeps Forum was lost, please wait while we try to reconnect.