For some reason mods that only rely on the NotifyOnNewObject() function to change properties under "/Script/Pal.PalGameSetting" don't work very well for me. Sometimes they will load properly and everything will be fine, but other times they won't works at all. It really depends on what other mods do you have installed and if they are also using the NotifyOnNewObject() function to change properties under the same PalGameSetting script.
So in order to avoid this and make them more reliable, I've discarded the use of NotifyOnNewObject() and replaced it with a direct RegisterHook() call to the parameters themself.
The refined code for this mod will look as follows :
main.lua local palConfig = require "config"
-- Prints the mod successful loading message in red print(palConfig.palRedColorWrapperFront .. palConfig.palModName .. " version " .. palConfig.palModVersion .. " loaded for game version " .. palConfig.palGameVersion .. palConfig.palRedColorWrapperBack)
-- Register the new modifiers and print a successful change message in red RegisterHook("/Script/Engine.PlayerController:ClientRestart", function() if palConfig.palCheckRestart ~= 1 then local items = FindAllOf("PalGameSetting") if items then for _, item in ipairs(items) do item.Swimming_SP_Idle = palConfig.palSwimmingStamina item.Swimming_SP_Swim = palConfig.palSwimmingStamina item.Swimming_SP_DashSwim = palConfig.palSwimmingStamina end end print(palConfig.palRedColorWrapperFront .. palConfig.palModName .. " set to " .. palConfig.palSwimmingStamina .. palConfig.palRedColorWrapperBack) end palConfig.palCheckRestart = 1 end)
config.lua local palConfig = {
-- Change those for new mod or different version palModName = "Unlimited Swimming Stamina", palModVersion = "0.2", palGameVersion = "0.1.4.0",
-- Those are generic for every mod palCheckRestart = 0, palRedColorWrapperFront = "\27[31m", palRedColorWrapperBack = "\27[0m\n",
With this, you can ensure that the mod will always be loaded, and these settings will be injected under PalGameSetting, regardless of any other scripts attempting modifications in the same scope.
I've also added some visual enhancements like printing the mod loading messages in red, so they are more easily distinguished, but you can discard those if you don't like them. Feel free to use this version of the mod for a future update if you feel like it,
1 comment
For some reason mods that only rely on the NotifyOnNewObject() function to change properties under "/Script/Pal.PalGameSetting" don't work very well for me. Sometimes they will load properly and everything will be fine, but other times they won't works at all. It really depends on what other mods do you have installed and if they are also using the NotifyOnNewObject() function to change properties under the same PalGameSetting script.
So in order to avoid this and make them more reliable, I've discarded the use of NotifyOnNewObject() and replaced it with a direct RegisterHook() call to the parameters themself.
The refined code for this mod will look as follows :
main.lua
local palConfig = require "config"
-- Prints the mod successful loading message in red
print(palConfig.palRedColorWrapperFront .. palConfig.palModName .. " version " .. palConfig.palModVersion .. " loaded for game version " .. palConfig.palGameVersion .. palConfig.palRedColorWrapperBack)
-- Register the new modifiers and print a successful change message in red
RegisterHook("/Script/Engine.PlayerController:ClientRestart", function()
if palConfig.palCheckRestart ~= 1 then
local items = FindAllOf("PalGameSetting")
if items then
for _, item in ipairs(items) do
item.Swimming_SP_Idle = palConfig.palSwimmingStamina
item.Swimming_SP_Swim = palConfig.palSwimmingStamina
item.Swimming_SP_DashSwim = palConfig.palSwimmingStamina
end
end
print(palConfig.palRedColorWrapperFront .. palConfig.palModName .. " set to " .. palConfig.palSwimmingStamina .. palConfig.palRedColorWrapperBack)
end
palConfig.palCheckRestart = 1
end)
config.lua
local palConfig = {
-- Change those for new mod or different version
palModName = "Unlimited Swimming Stamina",
palModVersion = "0.2",
palGameVersion = "0.1.4.0",
-- Those are generic for every mod
palCheckRestart = 0,
palRedColorWrapperFront = "\27[31m",
palRedColorWrapperBack = "\27[0m\n",
-- Change modifier if needed, 0 = infinite
palSwimmingStamina = 0
}
return palConfig
With this, you can ensure that the mod will always be loaded, and these settings will be injected under PalGameSetting, regardless of any other
scripts attempting modifications in the same scope.
I've also added some visual enhancements like printing the mod loading messages in red, so they are more easily distinguished, but you can discard those if you don't like them. Feel free to use this version of the mod for a future update if you feel like it,
Gratitude