PTR- Can't create RoomPosition objects


  • Culture

    Using both new RoomPosition(x, y) and room.getPositionAt(x, y) is returning this bug-

    Error: invalid arguments in RoomPosition constructor
    at new RoomPosition (/opt/ptr/engine/dist/game/rooms.js:1016:19)
    at Room.data.Room.privateStore.(anonymous function).positionsSetCache.Room.find.Room.findPath.Room.getPositionAt (/opt/ptr/engine/dist/game/rooms.js:856:16)

    The above call is for the room W2S26 and the position 26, 23. 

    For some reason this bug does not show up in the console, only when calling from scripts.


  • Dev Team

    new RoomPosition constructor accepts three arguments, not two.getPositionAt should work though. What is the exact snippet of code?


  • Culture

    I figured out the problem. Previously you allowed "x" and "y" to be either strings or integers. However, you recently changed something and made it so only integers, not strings (even if those strings happened to be integers), can be used. So in my case the '26' and '23' were strings and thus were throwing an error.

    If anyone else encounters this it can be resolved using parseInt(). Artem, you may want to consider reverting to the previous behavior by using 'parseInt' when 'typeof' returns string, or by switching from whatever check you're using (I'm guessing a typeof number type thing) to the Number.isInteger check.