Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Starts Noita from the given path, optionally with a specific seed set.
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(DefaultParameterSetName = 'Default')]
param(
[Parameter()]
[string]
$Path = "C:\Program Files (x86)\Steam\steamapps\common\Noita",
[Parameter(Position = 0, ParameterSetName = 'Default')]
[long]
$Seed,
[Parameter(ParameterSetName = 'Default')]
[switch]
$DevMode,
[Parameter(Mandatory, ParameterSetName = 'Unpack')]
[switch]
$UnpackData
)
$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 = $Path | 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'
)
}
elseif ($UnpackData) {
$noitaArgs = @(
'-wizard_unpak'
)
}
$filename = if ($DevMode) {
'noita_dev.exe'
}
else {
'noita.exe'
}
$executable = Join-Path $Path -ChildPath $filename
try {
Push-Location $Path
& $executable @noitaArgs
}
finally {
Pop-Location
}
}
@Deathcon2

This comment has been minimized.

Copy link

@Deathcon2 Deathcon2 commented May 2, 2021

Noita now has 10 digit seeds that are sometimes generated. Int is no longer a compatible data type for those. I had to change Int at line 46 to long for it to work.

@vexx32

This comment has been minimized.

Copy link
Owner Author

@vexx32 vexx32 commented May 2, 2021

Thanks! I'll update the gist.

@bartekzwartek

This comment has been minimized.

Copy link

@bartekzwartek bartekzwartek commented Aug 22, 2021

I don't know about programming, I just wanted to upload a seed but I get an error

At line:76 char:1

  • }Start-Noita
  • ~
    Unexpected token '}' in expression or statement.
    • CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : UnexpectedToken
@vexx32

This comment has been minimized.

Copy link
Owner Author

@vexx32 vexx32 commented Aug 23, 2021

You must have missed part of the file when pasting it. You need to copy the entire file.

@JordanShurmer

This comment has been minimized.

Copy link

@JordanShurmer JordanShurmer commented Aug 24, 2021

There's a mod for starting with a Seed now. FYI for others who find this looking for that functionality:
https://steamcommunity.com/sharedfiles/filedetails/?id=2284931352

@vexx32

This comment has been minimized.

Copy link
Owner Author

@vexx32 vexx32 commented Aug 24, 2021

Aye, mods work, but certain game functionality is disabled with mods enabled, which is why this script exists. 🙂

@bartekzwartek

This comment has been minimized.

Copy link

@bartekzwartek bartekzwartek commented Aug 26, 2021

https://imgur.com/a/4TyuEGM
It seems fine to me, but it doesn't want to work.
Maybe I missed something

@vexx32

This comment has been minimized.

Copy link
Owner Author

@vexx32 vexx32 commented Aug 26, 2021

Like I said, you need to copy the whole file. Help comments at the start are inside of the function declaration, so if you cut those off, you've also cut off the function Start-Noita { declaration. If you copy the file as a whole, without leaving bits out, it'll work. 🙂

@bartekzwartek

This comment has been minimized.

Copy link

@bartekzwartek bartekzwartek commented Aug 26, 2021

I'm an idiot :D :D
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment