PSThar: PowerShell for Abiathar

Here is where to post about the latest Commander Keen fangame or modification you've finished, a new website you've made, or another Keen-related creation.
Post Reply
User avatar
Fleexy
Tool Smith
Posts: 1432
Joined: Fri Dec 12, 2008 1:21
Location: Abiathar C&C

PSThar: PowerShell for Abiathar

Post 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
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Re: PSThar: PowerShell for Abiathar

Post 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.
out now (link) : Image
User avatar
Levellass
S-Triazine
Posts: 5265
Joined: Tue Sep 23, 2008 6:40

Re: PSThar: PowerShell for Abiathar

Post by Levellass »

*Hugs her batch files*
What you really need, not what you think you ought to want.
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Re: PSThar: PowerShell for Abiathar

Post 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.
out now (link) : Image
Post Reply