Skip to content

Instantly share code, notes, and snippets.

@logchan
Last active May 30, 2021 20:23
Show Gist options
  • Save logchan/1d5935709dea5f1288241c7adafb04fd to your computer and use it in GitHub Desktop.
Save logchan/1d5935709dea5f1288241c7adafb04fd to your computer and use it in GitHub Desktop.
Generate live_streams.sii from list of definitions.
# Convert-LiveStreams.ps1
# Place this file and live_streams.txt in your ETS2 document folder
# Put your streams in live_streams.txt, one each line, like (include the quotes!):
# "http://example.com/|Some Radio|Sim radio|CN|128|0"
# Lines starting with # are ignored, so you can switch them on/off
# Right-click this script and run with PowerShell, it will generate live_streams.sii
$ErrorActionPreference = "Stop";
$nn = [Environment]::NewLine;
$lines = New-Object Collections.Generic.List[String];
foreach ($l in Get-Content ".\live_streams.txt" -Encoding utf8) {
$line = $l.Trim();
if ($line.StartsWith("#") -or ($line.Length -eq 0)) {
continue;
}
$lines.Add($line);
}
$output = "SiiNunit$nn{$($nn)live_stream_def : .live_streams {$nn";
$output += " stream_data: $($lines.Count)$nn";
$counter = 0;
foreach ($line in $lines) {
$output += " stream_data[$counter]: $line$nn";
$counter += 1;
}
$output += "}$nn}$nn";
Write-Host $output;
Set-Content -Path ".\live_streams.sii" -Value $output -Encoding utf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment