Skip to content

Instantly share code, notes, and snippets.

@aytch
Created April 2, 2021 14:57
Show Gist options
  • Select an option

  • Save aytch/796d7073b991860dadcaa2e162aa2ed5 to your computer and use it in GitHub Desktop.

Select an option

Save aytch/796d7073b991860dadcaa2e162aa2ed5 to your computer and use it in GitHub Desktop.
Powershell $PROFILE functions for Noita. You can start Noita with a specific seed, and/or set all the game flags back to unmodded (after you save and quit). If you don't have a powershell profile, open Powershell and run: 'New-Item -Type File -Path $PROFILE -force', then run: 'notepad $PROFILE' and paste the contents below and save the file. Rel…
function Start-Noita {
<#
.SYNOPSIS
Starts Noita from a PowerShell prompt, optionally with a specific set seed for a new game.
.DESCRIPTION
To use this function, copy and paste the complete function definition into a PowerShell
session, and then invoke it with `Start-Noita`. Supply `-Seed somevalue` if you would like
to run a specific seed (see the examples below).
.EXAMPLE
PS> Start-Noita
Starts Noita normally.
.EXAMPLE
PS> Start-Noita -Seed 1
Starts Noita with a fixed seed value of 1.
.EXAMPLE
PS> Start-Noita -Seed 1 -Path C:\Noita\noita.exe
Starts Noita from the requested location with a fixed seed value of 1.
Use this form if your copy of Noita was not installed via Steam, or modify the default
setting for $Path below before loading the function into your PowerShell session.
.NOTES
If you want, you can load this function into your PowerShell profile as follows:
1. Copy the entire function definition from top to bottom to your Windows clipboard (Ctrl+C).
2. Run the following code in PowerShell:
Get-Clipboard | Add-Content -Path $profile
3. Close and reopen PowerShell to load the newly modified profile.
4. Run `Start-Noita` directly as needed. It will be automatically loaded in any future PowerShell sessions.
#>
[CmdletBinding()]
param(
[Parameter()]
[string]
$Path = "C:\Program Files (x86)\Steam\steamapps\common\Noita\noita.exe",
[Parameter(Position = 0)]
[int]
$Seed
)
$noitaArgs = @()
$noitaFolder = $Path | Split-Path -Parent
if ($Seed) {
$xml = [System.Xml.XmlDocument]::new()
$node = $xml.CreateElement('MagicNumbers')
$xml.AppendChild($node) > $null
$blank = $xml.CreateTextNode([Environment]::NewLine)
$node.AppendChild($blank) > $null
$node.SetAttribute('WORLD_SEED', $Seed)
$node.SetAttribute('_DEBUG_DONT_LOAD_OTHER_MAGIC_NUMBERS', 1)
$node.SetAttribute('_DEBUG_DONT_SAVE_MAGIC_NUMBERS', 1)
$magicPath = $noitaFolder | Join-Path -ChildPath 'magic.txt'
$sb = [System.Text.StringBuilder]::new()
$xmlWriter = [System.Xml.XmlWriter]::Create(
$sb,
@{
Indent = $true
NewLineOnAttributes = $true
OmitXmlDeclaration = $true
}
)
$xml.Save($xmlWriter)
$xmlText = $sb.ToString()
Write-Verbose $xmlText
$xmlText | Set-Content -Path $magicPath
$noitaArgs = @(
'-no_logo_splashes'
'-magic_numbers', 'magic.txt'
)
}
try {
Push-Location $noitaFolder
& $Path @noitaArgs
}
finally {
Pop-Location
}
}
function Set-NoitaUnmodded {
[CmdletBinding()]
param(
[Parameter()]
[string]
$WorldPath = "$env:USERPROFILE\AppData\LocalLow\Nolla_Games_Noita\save00\world_state.xml",
[Parameter()]
[string]
$ModPath = "$env:USERPROFILE\AppData\LocalLow\Nolla_Games_Noita\save00\mod_config.xml"
)
[xml]$world = Get-Content -Path $WorldPath
$world.Entity.WorldStateComponent.mods_have_been_active_during_this_run = "0"
$world.OuterXml | Set-Content -Path $WorldPath
[xml]$mods = Get-Content -Path $ModPath
$mods.ChildNodes.Mod | ForEach-Object { $_.enabled = "0" }
$mods.OuterXml | Set-Content -Path $ModPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment