programmable branch switching



  • hi everyone first time poster here been playing over a month so far and i have a question which im not sure anyone ive met has thought about and here it is.

    what im wonder is, is it possible to code a condition to switch code branches under a condition instead of having to do it manually.

    for example having it count the number of containers in the room and if it has reached the required number having it switch to a different code branch that has the whole room do different things such as spawning more/bigger creeps


  • YP

    You should not use branches to do different things. They are ment to keep backups of working code or testing different code branches.

    You will soon have multiple rooms, so you better do it a different way you can't set a branch per room. For example write different functions to handle the room and if your requirements are met stop calling the first function and call the second function instead.

    Or you could use classes or whatever 🙂



  • As W4rl0ck said, don't use branches, use functions and modules.

    I have multiple variations of code all inside one branch and call the relevant modules based on the size of the controller in the room.

    Now cleaning up your code and removing any hardcoded assumptions you've made is an entirely different thing 🙂