Project Zomboid

Project Zomboid

Meditation
Burryaga  [developer] 13 Dec, 2023 @ 7:57pm
Lifestyle Compatibility Support - Removes Sound Effect
It has come to my attention that some other mod used in combination with this mod adds sound effects to meditation; those sound effects are part of Lifestyle's meditation, but I think some mods run both this (which at the time of release was the only meditation mod in Zomboid to my knowledge) and Lifestyle's (which is actually a distinct version of meditation with its own timed action and skill progression).

Formerly, I had linked to a less-than-ideal override patch that had patched out this behavior, but I have written my own much cleaner variation on muting that sound and included it as a Mod Option. Please check Mod Options for a checkbox that will allow you to meditate silently using Lifestyle's meditation if you use both of these mods together. This is off by default to respect the original intent of the creator of Lifestyle (although I definitely meditate in silence).

These mods are to my knowledge 100% compatible, but this mod is not integrated with Lifestyle's skill tree; this mod serves different purposes (such as pausing online play under safe conditions without logging out).
Last edited by Burryaga; 11 Feb, 2024 @ 9:06pm
< >
Showing 1-11 of 11 comments
dhireal 5 Jan, 2024 @ 4:43pm 
lol
ElfpireEva 18 Feb, 2024 @ 12:18am 
...Less clean? All I did was add a single lua file and line of code that just routed the call for a sound to null- that's about as clean of a patch as you can get.

That being said- I do very much like the sandbox option, I might disagree about it being 'cleaner' but I do believe giving someone the choice via sandbox options to be the better of the to resources.
Burryaga  [developer] 18 Feb, 2024 @ 2:37am 
No offense intended! Let me be clearer about the difference:

In your edit, you use about 200 lines of code, add an anonymous event function that cannot be removed or modified by others (because it's anonymous), and you ultimately adjust 2 functions; the anonymous function, and another function with the following signature:

onMeditateMenu(worldobjects, player, soundFile, length, level, xp, boredomReduction, stressReduction, neckPain, actionType)

You also overwrite that function in a way that would be incompatible with updates to that function, since you do not reproduce its original behavior by function-copying, but rather by directly copying its current lines of code.

(EDIT: In fact, your original edit would override the entire original file, at second glance, because you reuse the original file name in the same location; therefore it would overwrite all changes to that file if both mods were loaded together in the future.)

In my new solution, the entire file that fixes the problem is 20 lines *including empty lines that purely exist for spacing and legibility*, so it's 1/10 as much code; it only edits one function; and the modified function uses the technique known as "function decoration" to ensure that whatever the original function does will still happen exactly as it does even if that function is updated *as long as the first two variables in its signature do not change*. My solution is so brief that I can post it in its entirety here:

-- Lifestyle Sound Effect Silencer require("TimedActions/MeditateAction") if not (MeditateAction and MeditateAction.new) then return end Yogi = Yogi or {} Yogi.MeditationAction = {} Yogi.MeditationAction.new = MeditateAction.new function MeditateAction:new(player, sound, ...) if Yogi.mod.options.meditateSilently then sound = "DisableSoundEffects" end return Yogi.MeditationAction.new(self, player, sound, ...) end

As you can see, I actually call the original function in order to trigger all original behavior, and therefore if a patch adjusted what that function does, my decoration would likely remain compatible with said patch. That's what I mean by "cleaner" -- but I did not mean offense by that word choice. Your solution was effective for the current versions of the mods; it was just doing a bit more than it needed to be doing.
Last edited by Burryaga; 18 Feb, 2024 @ 2:46am
ElfpireEva 18 Feb, 2024 @ 2:49am 
That makes a lot more sense- I didnt take any offence I just didnt know what you meant by dirty- this expalins it very well though!
Burryaga  [developer] 18 Feb, 2024 @ 3:40am 
Originally posted by TheIrishSailor:
That makes a lot more sense- I didnt take any offence I just didnt know what you meant by dirty- this expalins it very well though!

<3 Thank you nonetheless for handling this compatibility while I was away from modding. I still love that you did that.
ElfpireEva 4 Mar, 2024 @ 5:47pm 
No problem but given there is now a mod option for it in this mod, there is no longer a use for mine, I will be depreciating my patch and after a time deleting it, which I am very happy to do because it's always a good day when a patchwork mod fixing a minor issue is no longer needed =)
grammarsalad 6 Jun, 2024 @ 7:37am 
How do these mods work together? Are there, like, two different kinds of meditation, or are they integrated in some way? I guess my ideal would be if the effects of this version w were based on the meditation skill (e.g. low levels see some emotional improvements that increase with level, while getting some of the other benefits at higher levels)
Burryaga  [developer] 6 Jun, 2024 @ 9:41am 
Originally posted by grammarsalad:
How do these mods work together? Are there, like, two different kinds of meditation, or are they integrated in some way? I guess my ideal would be if the effects of this version w were based on the meditation skill (e.g. low levels see some emotional improvements that increase with level, while getting some of the other benefits at higher levels)

Yes, there are two kinds of Meditation. The one with the icon comes from Lifestyle. The one with no icon is mine. I have not integrated this mod's behaviors with the skill tree in Lifestyle, but I did write this mod in such a way that patching it to do so would be entirely doable. I can't promise ever getting around to it myself, but I might help a bit here and there if you decide to tackle that integration and DM me on Discord (same name there).
grammarsalad 6 Jun, 2024 @ 7:16pm 
Oh, see, that is not a terrible idea. If I was to do something like that, it would be to just do an add on for this mod to add the skill (but that would work with lifestyles if also installed). Tbh, that would be a fun project for my first zomboid mod...

So ya, i might just do that
Burryaga  [developer] 6 Jun, 2024 @ 7:30pm 
Good luck! Let me know on the PZ Discord if you get stuck and I'll try to get you unstuck.
grammarsalad 6 Jun, 2024 @ 8:11pm 
Appreciated!
< >
Showing 1-11 of 11 comments
Per page: 1530 50