Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set palworldsettings via envsubst and templating #207

Merged
merged 15 commits into from
Feb 7, 2024

Conversation

MSpreckels
Copy link
Contributor

Hi there!

I've got another idea for setting the PalWorldSettings.ini!

In my example I use a template file that has environment variables set for each parameter. Using envsubst I patch those env vars in while also setting a default value for each.

I have tested if the variables are set in file but not ingame, yet.

@Twinki14
Copy link
Contributor

Twinki14 commented Jan 29, 2024

This is way cleaner, way easier to maintain long-term, and moves server settings directly to wherever the container image is declared. That's big.

Some things to test,

  • Server name / description, something with spaces, SERVER_NAME="A server with spaces in it's name"

@MSpreckels
Copy link
Contributor Author

I wanted to wait for some feedback before i continue working on it and building it further. There is still alot to test about e.g. i already saw that string arent properly parsed. Will continue work on this tomorrow

@thijsvanloef
Copy link
Owner

@MSpreckels Keep doing that you are doing, this sounds like an awesome solution

@MSpreckels
Copy link
Contributor Author

i've tested it, works for me.

Some considerations:

  • Should i keep the debug output?
  • What kind of naming do i use for envronment variables?
    • SERVER_PLAYER_MAX_NUM vs PLAYERS

Tagging you @Twinki14 @thijsvanloef because you were commenting

@thijsvanloef
Copy link
Owner

@MSpreckels keep the naming as close to the PalWorldSettings.ini, except for the ones that introduce breaking changes.

Tonight I'll test your PR as well, thanks for all your work

@thijsvanloef
Copy link
Owner

thijsvanloef commented Jan 30, 2024

Also some more things to test:

@MSpreckels
Copy link
Contributor Author

@MSpreckels keep the naming as close to the PalWorldSettings.ini, except for the ones that introduce breaking changes.

Tonight I'll test your PR as well, thanks for all your work

will check that tomorrow

Also some more things to test:

These are the results when i put the values in the config map:

  1. https://i.imgur.com/ie7T2L0.png
  2. https://i.imgur.com/0xZVgkb.png
  3. https://i.imgur.com/m2xlytD.png

SERVER_NAME = value and SERVER_NAME = "value" give the same results

SERVER_NAME = "\"value\"" breaks it tho

if you could test it using the docker command would be nice

@MSpreckels MSpreckels marked this pull request as ready for review January 30, 2024 19:20
@thijsvanloef
Copy link
Owner

@MSpreckels As for the debug question (sorry missed it completely) I would like a DEBUG env var to switch them on. But disable them by default

@thijsvanloef
Copy link
Owner

@MSpreckels Initial testing does not seem very succesfull, all PalWorldSettings.ini are set correctly, however it does not seem to work ingame:
PalWorldSettings.ini

[/Script/Pal.PalGameWorldSettings]
OptionSettings=(
Difficulty=None,
DayTimeSpeedRate=1.000000,
NightTimeSpeedRate=1.000000,
ExpRate=1.000000,
PalCaptureRate=1.000000,
PalSpawnNumRate=1.000000,
PalDamageRateAttack=1.000000,
PalDamageRateDefense=1.000000,
PlayerDamageRateAttack=1.000000,
PlayerDamageRateDefense=1.000000,
PlayerStomachDecreaceRate=1.000000,
PlayerStaminaDecreaceRate=1.000000,
PlayerAutoHPRegeneRate=1.000000,
PlayerAutoHpRegeneRateInSleep=1.000000,
PalStomachDecreaceRate=1.000000,
PalStaminaDecreaceRate=1.000000,
PalAutoHPRegeneRate=1.000000,
PalAutoHpRegeneRateInSleep=1.000000,
BuildObjectDamageRate=1.000000,
BuildObjectDeteriorationDamageRate=1.000000,
CollectionDropRate=1.000000,
CollectionObjectHpRate=1.000000,
CollectionObjectRespawnSpeedRate=1.000000,
EnemyDropItemRate=1.000000,
DeathPenalty=All,
bEnablePlayerToPlayerDamage=False,
bEnableFriendlyFire=False,
bEnableInvaderEnemy=True,
bActiveUNKO=False,
bEnableAimAssistPad=True,
bEnableAimAssistKeyboard=False,
DropItemMaxNum=3000,
DropItemMaxNum_UNKO=100,
BaseCampMaxNum=128,
BaseCampWorkerMaxNum=15,
DropItemAliveMaxHours=1.000000,
bAutoResetGuildNoOnlinePlayers=False,
AutoResetGuildTimeNoOnlinePlayers=72.000000,
GuildPlayerMaxNum=20,
PalEggDefaultHatchingTime=72.000000,
WorkSpeedRate=1.000000,
bIsMultiplay=False,
bIsPvP=False,
bCanPickupOtherGuildDeathPenaltyDrop=False,
bEnableNonLoginPenalty=True,
bEnableFastTravel=True,
bIsStartLocationSelectByMap=True,
bExistPlayerAfterLogout=False,
bEnableDefenseOtherGuildPlayer=False,
CoopPlayerMaxNum=4,
ServerPlayerMaxNum=16,
ServerName="World of Pals",
ServerDescription="Dit is een Test",
AdminPassword="adminPasswordHere",
ServerPassword="Test 123 ofpals",
PublicPort=8211,
PublicIP="",
RCONEnabled=true,
RCONPort=25575,
Region="",
bUseAuth=True,
BanListURL="https://api.palworldgame.com/api/banlist.txt"
)

Logs:

palworld-server  | *****GENERATING CONFIGS*****
palworld-server  | ====Debug====
palworld-server  | DIFFICULTY = None
palworld-server  | DAY_TIME_SPEED_RATE = 1.000000
palworld-server  | NIGHT_TIME_SPEED_RATE = 1.000000
palworld-server  | EXP_RATE = 1.000000
palworld-server  | PAL_CAPTURE_RATE = 1.000000
palworld-server  | PAL_SPAWN_NUM_RATE = 1.000000
palworld-server  | PAL_DAMAGE_RATE_ATTACK = 1.000000
palworld-server  | PAL_DAMAGE_RATE_DEFENSE = 1.000000
palworld-server  | PLAYER_DAMAGE_RATE_ATTACK = 1.000000
palworld-server  | PLAYER_DAMAGE_RATE_DEFENSE = 1.000000
palworld-server  | PLAYER_STOMACH_DECREACE_RATE = 1.000000
palworld-server  | PLAYER_STAMINA_DECREACE_RATE = 1.000000
palworld-server  | PLAYER_AUTO_HPREGENE_RATE = 1.000000
palworld-server  | PLAYER_AUTO_HP_REGENE_RATE_IN_SLEEP = 1.000000
palworld-server  | PAL_STOMACH_DECREACE_RATE = 1.000000
palworld-server  | PAL_STAMINA_DECREACE_RATE = 1.000000
palworld-server  | PAL_AUTO_HPREGENE_RATE = 1.000000
palworld-server  | PAL_AUTO_HP_REGENE_RATE_IN_SLEEP = 1.000000
palworld-server  | BUILD_OBJECT_DAMAGE_RATE = 1.000000
palworld-server  | BUILD_OBJECT_DETERIORATION_DAMAGE_RATE = 1.000000
palworld-server  | COLLECTION_DROP_RATE = 1.000000
palworld-server  | COLLECTION_OBJECT_HP_RATE = 1.000000
palworld-server  | COLLECTION_OBJECT_RESPAWN_SPEED_RATE = 1.000000
palworld-server  | ENEMY_DROP_ITEM_RATE = 1.000000
palworld-server  | DEATH_PENALTY = All
palworld-server  | ENABLE_PLAYER_TO_PLAYER_DAMAGE = False
palworld-server  | ENABLE_FRIENDLY_FIRE = False
palworld-server  | ENABLE_INVADER_ENEMY = True
palworld-server  | ACTIVE_UNKO = False
palworld-server  | ENABLE_AIM_ASSIST_PAD = True
palworld-server  | ENABLE_AIM_ASSIST_KEYBOARD = False
palworld-server  | DROP_ITEM_MAX_NUM = 3000
palworld-server  | DROP_ITEM_MAX_NUM_UNKO = 100
palworld-server  | BASE_CAMP_MAX_NUM = 128
palworld-server  | BASE_CAMP_WORKER_MAX_NUM = 15
palworld-server  | DROP_ITEM_ALIVE_MAX_HOURS = 1.000000
palworld-server  | AUTO_RESET_GUILD_NO_ONLINE_PLAYERS = False
palworld-server  | AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS = 72.000000
palworld-server  | GUILD_PLAYER_MAX_NUM = 20
palworld-server  | PAL_EGG_DEFAULT_HATCHING_TIME = 72.000000
palworld-server  | WORK_SPEED_RATE = 1.000000
palworld-server  | IS_MULTIPLAY = False
palworld-server  | IS_PVP = False
palworld-server  | CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP = False
palworld-server  | ENABLE_NON_LOGIN_PENALTY = True
palworld-server  | ENABLE_FAST_TRAVEL = True
palworld-server  | IS_START_LOCATION_SELECT_BY_MAP = True
palworld-server  | EXIST_PLAYER_AFTER_LOGOUT = False
palworld-server  | ENABLE_DEFENSE_OTHER_GUILD_PLAYER = False
palworld-server  | COOP_PLAYER_MAX_NUM = 4
palworld-server  | SERVER_PLAYER_MAX_NUM = 16
palworld-server  | SERVER_NAME = "World of Pals"
palworld-server  | SERVER_DESCRIPTION = "Dit is een Test"
palworld-server  | ADMIN_PASSWORD = "adminPasswordHere"
palworld-server  | SERVER_PASSWORD = "Test 123 ofpals"
palworld-server  | PUBLIC_PORT = 8211
palworld-server  | PUBLIC_IP = ""
palworld-server  | RCON_ENABLED = true
palworld-server  | RCON_PORT = 25575
palworld-server  | REGION = ""
palworld-server  | USE_AUTH = True
palworld-server  | BAN_LIST_URL = "https://api.palworldgame.com/api/banlist.txt"
palworld-server  | ====Debug====
palworld-server  | *****STARTING SERVER*****
palworld-server  | ./PalServer.sh -port=8211 -queryport=27015 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS
palworld-server  | [S_API] SteamAPI_Init(): Loaded local 'steamclient.so' OK.
palworld-server  | Shutdown handler: initalize.
palworld-server  | Increasing per-process limit of core file size to infinity.
palworld-server  | CAppInfoCacheReadFromDiskThread took 8 milliseconds to initialize
palworld-server  | Setting breakpad minidump AppID = 2394010
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.

In Game:
image

It also seems to accept any password as long as there is one set

Repository owner deleted a comment from vhladiienko Jan 30, 2024
@Twinki14
Copy link
Contributor

Initial testing does not seem very succesfull, all PalWorldSettings.ini are set correctly, however it does not seem to work ingame: PalWorldSettings.ini

This is more likely a problem with the formatting of the ini file, all settings may need to be on one line.

The values are reaching the ini file, which is a really good sign for this method. Now we just need to get the ini formatted correctly so that the server picks up the settings properly.

@Twinki14
Copy link
Contributor

Twinki14 commented Jan 30, 2024

Some considerations:

  • Should i keep the debug output?
  • What kind of naming do i use for envronment variables?

In my opinion,

  • Let's always output the environment variables, it's very useful information to have and imo a informational level, not debug level. Outputting the full ini after compilation would also be a bonus - anyone looking at logs is already seeking to find information about something going wrong, so I see no reason to keep the env var logging specific to a "debug output" toggle
  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • DayTimeSpeedRate -> DAY_TIME_SPEED_RATE,
    • bIsPvP -> B_IS_PVP
    • Prefixing each environment variable with PALWORLD_SERVER_ might be smart, if we want to support "other" ini sections, but I don't think it's worthwhile
    • This would set us up nicely for the future if we ever wanted to automate the creation of the setting compilation script, we could read settings from a DefaultPalworldSettings.ini, and easily convert each setting to a environment variable counterpart

@MSpreckels
Copy link
Contributor Author

Hey thanks for testing! I wonder why it is not formatting correctly. I'm using tr to remove all the new lines. Might be a tooling difference between macos and linux? I'll check.

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • bIsPvP -> B_IS_PVP

I'd maybe remove type identifiers like b :)

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • Prefixing each environment variable with PALWORLD_SERVER_ might be smart, if we want to support "other" ini sections, but I don't think it's worthwhile

I don't like prefixing them. Some of those variables are already super long which would make it more unreadable.

  • Take the setting and convert it to SNAKE_CASE, that should be the environment variable naming scheme.
    • ...
    • This would set us up nicely for the future if we ever wanted to automate the creation of the setting compilation script, we could read settings from a DefaultPalworldSettings.ini, and easily convert each setting to a environment variable counterpart

I like that idea!

@MSpreckels
Copy link
Contributor Author

As we talked about in discord: Ive now fixed the replacement of \n line ending to \n\r line ending. This still works on my end. I've also replaced some env vars that i set with some that already been set before.

Please test this, thoroughly.

@thijsvanloef
Copy link
Owner

I've done some initial testing and everything seems to work! Will test more thoroughly tomorrow. Thank you for all the work!

@chkpwd
Copy link

chkpwd commented Jan 31, 2024

Is this pushed to dev? @thijsvanloef

@Twinki14
Copy link
Contributor

I'd maybe remove type identifiers like b :)

I only included the modifier with the idea that eventually we'll have an automation script for the compilation script, identifying and dropping type identifiers might add to the logic complexity for such a script, but that is only an eventual idea.

I'm not partial in any direction.

@thijsvanloef
Copy link
Owner

@chkpwd no, but you can test it locally by checking out this branch and running:
docker build --tag thijsvanloef/palworld-server-docker:latest
And then running compose up

@Twinki14
Copy link
Contributor

Twinki14 commented Jan 31, 2024

Some final thoughts on this, and these are just my opinions

  • After this is merged, the next release should bump from 0.19.1 to 0.50.0, this PR should solidify how we're going to support server settings for probably awhile, and will override anyone's current custom ini's, this will very much be a big breaking change
  • If we agree on this, if we wait spend some time waiting before the 0.50.0 release, I can update the helm chart & example docker compose to instead use the "last compatible version" instead of latest, remove custom ini support, and remove the k8s manifests
  • The readme should also be updated in the timeframe between sitting in main and release

@Dashboy1998
Copy link
Contributor

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image.

If a value isn't defined the ini file then game seems to use the default value.

@Twinki14
Copy link
Contributor

Twinki14 commented Feb 1, 2024

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image.

If a value isn't defined the ini file then game seems to use the default value.

Hence why an automation script would be very valuable. A scheduled GitHub Action can regularly run, start a Palworld server, copy the DefaultPalworldSettings.ini, run an automation script against it, and then output the full compilation script with all default values.

@Dashboy1998
Copy link
Contributor

Since we define the default values in the compile-settings if the game updates and changes one of the default values then no one running the image would have the updated default values until we update the compile-settings file and they update their image.
If a value isn't defined the ini file then game seems to use the default value.

Hence why an automation script would be very valuable. A scheduled GitHub Action can regularly run, start a Palworld server, copy the DefaultPalworldSettings.ini, run an automation script against it, and then output the full compilation script with all default values.

Why not create the compilation script at container start up instead?

@Twinki14
Copy link
Contributor

Twinki14 commented Feb 1, 2024

Why not create the compilation script at container start up instead?

It needs a DefaultPalworldSettings.ini, which if it's populated when the server is installed from steamcmd, this might be doable. But I think keeping it outside the container will be better, for documentation purposes

@MSpreckels
Copy link
Contributor Author

  • After this is merged, the next release should bump from 0.19.1 to 0.50.0, this PR should solidify how we're going to support server settings for probably awhile, and will override anyone's current custom ini's, this will very much be a big breaking change

I really dont like that. We are in active early development, changes like that are to be expected. We should test the case when someone is using a save from previous versions and upgrades to a latest image where this change is implemented, so that we know what is going to happen. Maybe we can check for custom values in ini?
0.20.0 is sufficient IMO.

If a value isn't defined the ini file then game seems to use the default value.

Thats a good point, somehow I've never tried that.

Why not create the compilation script at container start up instead?

What do you mean by container start up? Do you mean in the init script? when the docker container is being build?

@Dashboy1998
Copy link
Contributor

In the start script read values in default ini to create the config script.

Been trying to find a good tool that let's you modify ini but none seem to support arrays.

@MSpreckels
Copy link
Contributor Author

In the start script read values in default ini to create the config script.

Been trying to find a good tool that let's you modify ini but none seem to support arrays.

Thats the thing. Pocket Pair's decision on making a giant array instead of separated values makes this so much harder.

@thijsvanloef
Copy link
Owner

Have to agree with @MSpreckels on the new tag, jumping the tag to 0.50 will probably not make any difference to 0.20
People who are on latest will update
People who fixed it on v0 tag will update
People who fixed it on v0.19 will not update
People who fixed it on v0.19.1 will not update

The only thing I will add is a breaking change warning in the release.

@MSpreckels MSpreckels marked this pull request as draft February 1, 2024 22:05
@iamspido
Copy link

iamspido commented Feb 6, 2024

When do you plan to merge this?

@MSpreckels MSpreckels marked this pull request as ready for review February 6, 2024 18:28
@thijsvanloef
Copy link
Owner

@iamspido @MSpreckels Initial testing resulted in no errors, will resume testing tomorrow and probably release tomorrow :)

@thijsvanloef
Copy link
Owner

Did some more testing today, was not able to find any errors, @MSpreckels once merge conflict has been resolved, ready to merge :)

@thijsvanloef thijsvanloef merged commit b41b178 into thijsvanloef:main Feb 7, 2024
5 checks passed
@iamspido
Copy link

iamspido commented Feb 8, 2024

I don't know if that was planned, but the environment variable BASE_CAMP_WORKER_MAXNUM has been changed to BASE_CAMP_WORKER_MAX_NUM.
By setting BASE_CAMP_WORKER_MAX_NUM: "20" it has no effect, and you're still limited to the default of 15.
However, the value 20 is correctly set in the palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.

@iamspido
Copy link

iamspido commented Feb 8, 2024

After some research, I found out that this seems to be an issue with Palworld itself.
There appears to be a workaround involving a WorldOptions.sav file that needs to be placed under palworld/Pal/Saved/SaveGames/0/<random>/WorldOptions.sav.
However, this overrides the PalWorldSettings.ini configuration.
It seems that you can generate such a WorldOptions.sav file at https://palworldoptions.com/ (not tested).

@Dashboy1998 Dashboy1998 mentioned this pull request Feb 8, 2024
3 tasks
MusclePr pushed a commit to MusclePr/palworld-server-docker that referenced this pull request Jun 19, 2024
set palworldsettings via envsubst and templating
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants