ValheimPlus sample config with environment variables #409
Answered
by
patrickdomnick
henrysachs
asked this question in
Q&A
-
Hey there, has anyone a Valheim plus Config created with env vars to start from? I would be happy if i didnt have to start from scratch :D |
Beta Was this translation helpful? Give feedback.
Answered by
patrickdomnick
Sep 22, 2021
Replies: 1 comment 2 replies
-
I did something in PowerShell function Get-IniContent ($filePath)
{
$ini = @{}
switch -regex -file $FilePath
{
"^\[(.+)\]" # Section
{
$section = $matches[1]
$ini[$section] = @{}
$CommentCount = 0
}
"^(;.*)$" # Comment
{
$value = $matches[1]
$CommentCount = $CommentCount + 1
$name = "Comment" + $CommentCount
$ini[$section][$name] = $value
}
"(.+?)\s*=(.*)" # Key
{
$name,$value = $matches[1..2]
$ini[$section][$name] = $value
}
}
return $ini
}
$conf = Get-IniContent("valheim_plus.cfg")
$lines = @()
foreach ($category in $conf.Keys) {
foreach ($key in $conf[$category].Keys) {
$value = $conf[$category][$key]
if ($value[0] -ne ";" -and $key[0] -ne ";") {
$line = "VPCFG_" + $category + "_" + $key + ": " + $value
$lines += $line
}
}
}
$lines | Out-File -Append valheim.yaml
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
henrysachs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did something in PowerShell