Saturday, February 18, 2017

PSThar - Set-LevelTile cmdlet

There are several steps necessary to correctly change a tile from the Abiathar API. First the tile in the level itself has to be set, then the render planes need to be notified of the change, then the undo stack has to be updated. If not all of those three things go together, bizarre behavior will result. That's too much for every scripter to remember and implement correctly all the time, so I wrote up a Set-LevelTile cmdlet for PSThar that takes care of all the details.

That was slightly trickier than expected because there's no way to get the ID of a given level wrapper without using reflection and scanning through all the current levels. That API oversight is usually mitigated by tools' easy access to the current level ID, but PSThar scripts can affect any level. I used the reflection strategy here, but I'll try to figure out some nice new API feature so other extension authors don't have to.

No comments:

Post a Comment