Cube 2: Sauerbraten: Difference between revisions

From LANCommander
No edit summary
No edit summary
 
Line 24: Line 24:
|Contents =
|Contents =
<syntaxhighlight lang="powershell" line>
<syntaxhighlight lang="powershell" line>
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay
$Display = Get-PrimaryDisplay
$Documents = [Environment]::GetFolderPath('MyDocuments')


# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^scr_w (.+)' -Substitution "scr_w $($Display.Bounds.Width)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_w (.+)' -Substitution "scr_w $($Display.Bounds.Width)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_h (.+)' -Substitution "scr_h $($Display.Bounds.Height)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_h (.+)' -Substitution "scr_h $($Display.Bounds.Height)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_w (.+)' -Substitution "scr_w $($Display.Bounds.Width)" -FilePath "$Documents\My Games\Sauerbraten\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_h (.+)' -Substitution "scr_h $($Display.Bounds.Height)" -FilePath "$Documents\My Games\Sauerbraten\init.cfg"
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 00:40, 22 February 2024

Release Date
Windows: December 31, 2004
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\sauerbraten.bat True

Install Script

$Display = Get-PrimaryDisplay
$Documents = [Environment]::GetFolderPath('MyDocuments')

Write-ReplaceContentInFile -Pattern '^scr_w (.+)' -Substitution "scr_w $($Display.Bounds.Width)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_h (.+)' -Substitution "scr_h $($Display.Bounds.Height)" -FilePath "$InstallDirectory\config\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_w (.+)' -Substitution "scr_w $($Display.Bounds.Width)" -FilePath "$Documents\My Games\Sauerbraten\init.cfg"
Write-ReplaceContentInFile -Pattern '^scr_h (.+)' -Substitution "scr_h $($Display.Bounds.Height)" -FilePath "$Documents\My Games\Sauerbraten\init.cfg"

Name Change Script

# Trim a string down to a specified amount of characters
if ($NewPlayerAlias.Length -gt 15) {
    $NewPlayerAlias = $NewPlayerAlias.Substring(0, 15);
}

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^name "(.+)"' -Substitution "name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\config\config.cfg"
Write-ReplaceContentInFile -Pattern '^newname \[.+\]' -Substitution "name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\config\config.cfg"