creep.room actually returns the room object during last tick
-
Which shard is affected?
shard3,but probably all shards are affacted.
What happened?
Writing my outpost code,my creep kept riding border when they cross the room.
I've logged the room name and found that actually creep.room returns the room object during the last tick,so the creep can't use the OLD room object to search for a container in NEW room.
For example,
I've reached the border of room A,Game.tick is 2,creep.room.name is room A
Next tick,I've reached room B,Game tick is 3,but creep.room.name is still room A
Next tick,I've gone back to room B,Game tick is 4,creep.room.name is room B
What should have happened?
When in tick 3(in the example),creep should get the room B object,not room A
How can we reproduce this?
Just...two rooms,send a creep and creep.say(creep.room) all the time while crossing border
I'm not sure if I described the problem correctly.Sorry for my bad English,but if there is anything I can help,just let me know.
-
This is because it doesn't take a tick to move to the next room, it's instantaneous, no commit is needed.
First: All creep movement resolves down to "creep.move(dir)" where dir is a direction constant, 1 to 8. 1 in due north, 8 is north west.4 is due south.
What's actually happening is when you register the intent "creep.move(4)" to move from tile 48 to tile 49 (The exit tile.) in the room above, you get moved all the way to tile 0 in the room below.
If the creep is talking, it will say what was registered to say in the previous tick, back when it was moving from tile 48.
If you're using "creep.moveTo()" or one of the stock path follower routines, the "lost tile" will be accounted for when crossing room boundaries, otherwise you have to manage it yourself.
I hope that makes sense. Room edge crossing can be a little hard to wrap your brain around, but there is logical sense behind it. That intent, where you leave the room, cannot fail as all you would have to do to block a room is jam creeps at the border.
-
I understood. Thanks for helping