I've noticed that a lot of the PSThar scripts I write involve looping through every single point in a level. Doing that in plain PowerShell is kind of a mess, involving either a select -pv plus a % or a C-style loop.
So today, I added a new cmdlet: ForEach-LevelTile. It takes either a level ID or a level wrapper plus a script block. It then executes the script block for every (x, y) coordinate in the level, setting the $x and $y variables (or variables by other names specified in optional parameters) as appropriate.
For convenience, I aliased %t to this cmdlet, like how plain % is ForEach-Object.
No comments:
Post a Comment