exaV / screeps-kotlin-starter

A starting point for a Screeps AI written in Kotlin
MIT License
46 stars 63 forks source link

Added examples of how to setup persistent variables for other classes #7

Closed codedraughtsman closed 4 years ago

codedraughtsman commented 4 years ago

When expanding on the starter package, I wanted to add variables to the persistent memory of the different object types in the game. It took me quite some time to figure out how to do this for objects other than creeps.

Hoping to help out future users of this package, I added comments and examples to BasicCreepMemory.kt on how to create a test variable for all of the classes that support persistent memory . Hopefully future users can use this as a quick reference.

I also moved BasicCreepMemory.kt to BasicMemory.kt, since it was now setting up more than just creeps.

Could you please merge this into the main project so that others can benefit from it. Thank you.

exaV commented 4 years ago

Thanks I this could be useful for newcomers. It would be nice if we also showed how to read/write one of properties in the code. E.g. write the number of creeps in the current rooms to its memory. If you can think of a better example go for it.

exaV commented 4 years ago

I added an example of how to use room.memory in the script https://github.com/exaV/screeps-kotlin-starter/commit/b8b5849af544bec71f1581e4ba6a9ce770034320

codedraughtsman commented 4 years ago

Thanks for adding the example :)