Technical Issues with Rooms



  • builder:Error: It seems you're trying to use a serialized game object stored in Memory which is not allowed. Please use `Game.getObjectById` to retrieve a live object reference instead.

     

    {\"x\":25,\"y\":25,\"roomName\":\"W42N81\"}

     

    im storing the room Coordinates as string in the memory of the creep...

    thats in no way a complicated game object... please help



  • Because memory is serialized any objects you put into it lose their prototype, so the next tick when you pull that position out, its no longer a RoomPosition. One of the checks involved in throwing the error you are getting is _.isPlainObject which would return false if the object has no prototype.

    One of several ways you can work around this is to pass the attributes you have stored in memory into the RoomPosition constructor to make a new RoomPosition object whenever you pull it out of memory. 

    `let myNewPosition = new RoomPosition(myMemoryPosition.x, myMemoryPosition.y, myMemoryPosition.roomName);`

    Also if you havent already, check out this link http://chat.screeps.com/ to get signed up for the https://screeps.slack.com/ slack team.
    There is a #help channel there where you can get pretty quick answers to questions like this.