Screeps: World
Motam Aug 13, 2017 @ 9:15pm
Can't harvest in non-reserved room
I am trying to harvest energy from a source in a non-reserved room. From what I read so far, this should be possible (apart from the Source being 1.5k instead of 3k). But so far I only get error code -7 (ERR_INVALID_TARGET).
I store the ID of the source in the creeps memory and before harvesting I extract it to a source object again using Game.getObjectById. Any pointers?
Cheers,
Motam
< >
Showing 1-3 of 3 comments
Motam Aug 13, 2017 @ 9:31pm 
Found my error: One can not getObjectById if one is not in the same room as the Object.
In my code, the getObjectById happened directly after the creep was spawned (i.e. not in the remote harvesting room). This lead to a 'null' object.
I changed to code to do the getObjectById once the creep was in the target room, this gave a proper reference to the energy source object and now I am happily harvesting away!

ps I won't delete the thread since I hope this helps others who stumble over this problem too.
Last edited by Motam; Aug 13, 2017 @ 9:32pm
Azrael Aug 14, 2017 @ 7:16am 
The creep itself doesn't have to be in the same room, you just need to have any unit in that room to get the object reference.
Motam Aug 14, 2017 @ 10:49am 
Thanks, for now it will be the only creep so he'll have to do it but good to know!
< >
Showing 1-3 of 3 comments
Per page: 1530 50