Page 1 of 1

PSThar: PowerShell for Abiathar

Posted: Tue Mar 14, 2017 20:07
by Fleexy
PowerShell is a really great command-line tool for Windows that is way better than ye olde batch. Wouldn't it be great if you could use it to write scripts that can manipulate Abiathar objects?

Well, now you can. PSThar is an Abiathar extension that provides a single tool (of the same name) to host a PowerShell runspace in the Abiathar process. You have access to everything that extensions have, without needing to compile anything. You can fiddle with internals if necessary, but be warned that it's possible to corrupt the project state with injudicious use of those abilities.

It presents a simple text field and a results view:

Image

Type as many lines of script as you like, hit Run Script (or do Shift+Enter), and you'll see the output in the lower pane. You can switch the view to see other types of feedback, like errors and warnings.

The $Abiathar variable is set to the state manager, the same one you get from the Abiathar API. $CurLevel is the level wrapper for the currently visible level. There are a few cmdlets that take care of some of the trickier bookkeeping for you:
  • Get-LevelTile: get the tile ID at a certain position, from either a level wrapper or a level ID
  • Set-LevelTile: set the tile ID at a certain position
  • Get-Level: get all the levels, or just one by name or ID
  • Get-TileProperties: get the tileinfo of a tile by its ID
  • Set-TileProperties: alter the tileinfo of a tile
  • Get-SelectedTile: get the currently selected tile for a plane
  • Set-SelectedTile: set the selected tile for a plane
  • New: ForEach-LevelTile: iterate over all positions in a level, running a script block with $x and $y set
These cmdlets take care of updating the undo history and marking planes dirty, and PSThar itself always causes a rerender after running a script. If you're manually adjusting things, take note that bookkeeping is not automatically handled - PSThar simply does what it's told.

Download PSThar

To use, drop the AEX next to Abiathar. You might have to "unblock" the downloaded file in its properties window first, depending on your browser.

Happy scripting!

Fleexy

Re: PSThar: PowerShell for Abiathar

Posted: Wed Mar 15, 2017 12:03
by Nisaba
hey... ohh... ahh...
sounds interesting.
and useful.
but complicated at the same time.
I'm sure it's not, but man... so much text...
Can you give lazy folks like me a quick video introduction for this neat little extra, please?! this might lower the feeling of being overstrained. it looks somehow straight forward but you must forgive me. my brain is, well, simple-minded when it comes to things like this...
but I'd love to test the powershell option.

Re: PSThar: PowerShell for Abiathar

Posted: Fri Mar 17, 2017 8:38
by Levellass
*Hugs her batch files*

Re: PSThar: PowerShell for Abiathar

Posted: Sun Mar 19, 2017 19:42
by Nisaba
tried my first PSThar Script with a fair help by Fleexy.
the script converted a "Carmacked" MAPTEMP.CK4 to the standard GAMEMAPS format and replaced a corrupted own instead.

Code: Select all

$fc = $Abiathar.FileConfig['Core']
$fc.MapType = 'Carmack'
$fc.MapFiles.GameMaps = 'GAMEMAPS.CK4'
Nice tool I must say.
big shout-out to Mr Fleex.