Project Zomboid

Project Zomboid

B42 Native ModOptions Example
35 条留言
Dustin 8 月 14 日 上午 1:54 
Please put this on github so we don't need to download a workshop mod to enjoy your work.
Robob27 8 月 5 日 上午 3:26 
The mod is not necessary for anything, it won't make anything work, nothing will show up in game. It's simply example code to help other mod developers learn how to expose options for their mods. That's it, that's all.
Apathy 7 月 28 日 上午 7:51 
Is it compatible with Britas?
Sweggles11 7 月 27 日 下午 12:19 
So is this necessary for Bandits in build 42 or nah?
ReZpawner 7 月 23 日 上午 11:07 
So this is getting pretty confusing - is this needed for Bandits in B42 or not? A lot of the information here seem to be conflicting.
TeeJaaY 7 月 2 日 下午 1:43 
this isnt a mod for anyone wondering. its nothing if you got here trying to get bandits to work
Michels 6 月 1 日 上午 10:17 
great work soldier
nakhrin 4 月 6 日 下午 2:48 
Thanks cdshmirtz
cdshmirtz 4 月 4 日 下午 4:12 
nakhrin, it is revolved around the Bandits mod, and this is the option for B42 users. At least that's how I got here.
nakhrin 4 月 3 日 下午 1:58 
Does this mod has any dependency on another mod? I don't recall downloading it.
Viruana 3 月 7 日 下午 3:32 
Appreciate it so much!!!
Lightja 2 月 1 日 下午 6:35 
legend!
Kyu 1 月 14 日 上午 8:40 
@Ivechy - Are you on build 42? Did you customize your own script for creating the options you want?

If so, create a discussion with your script and maybe I can help!
Invechy 1 月 14 日 上午 7:25 
no matter what i do i can not get this mod to show up in game. i have tried everything.
No' 1 月 11 日 上午 5:09 
Thanks for your work !
Arsenal[26] 1 月 11 日 上午 1:02 
Thanks dhert, good stuff
dhert  [作者] 2024 年 12 月 30 日 下午 5:50 
@molecule31 - This is a known issue that has been reported to the developers. The "Save" function for the new ModOptions saves to the file "ModOptions.ini". However, the "Load" function uses file "modOptions.ini". On Windows, this would be the same file. On Linux, this is 2 different files.
molecule31 2024 年 12 月 30 日 下午 3:10 
Hey, apparently, the mod menu on the Linux build works but does not save parameters I've banging my head against the wall for more than a week and all I had to do was put pz through proton to make the mod menu work, I'm so frustrated now
Notloc 2024 年 12 月 28 日 下午 12:15 
@dhert @PePePePePeil
There actually is a callback, but its for the whole object, not specific settings.
Your modOption object has an apply function you can override that is called whenever the user applies settings

Discussion link because comments do not allow adequate formatting:
https://psteamcommunity.yuanyoumao.com/workshop/filedetails/discussion/3386860561/595136643598386903/
NICETRY 2024 年 12 月 23 日 上午 1:33 
Thanks for the work done, very useful information.
N0wh3re 2024 年 12 月 22 日 上午 5:09 
This guy is the best.
PePePePePeil 2024 年 12 月 21 日 上午 6:43 
@dhert
Thank you for your response and development request. I was hoping to process it only once when it is changed instead of every time to improve processing performance, I look forward to the ModOptions update, thank you! :spiffo:
dhert  [作者] 2024 年 12 月 21 日 上午 6:13 
@PePePePePeil - Unfortunately no, there's no function called when you change your options that you can hook in to. You'll just either have to keep querying your options directly when needed.
There's a "Modding Request" thread on the official Zomboid Discord, and I requested that an event be created when changes are applied (even provided a snippet of code for them to accomplish this), so hopefully there will be an event in a future update that you can use to re-read all of your settings.
PePePePePeil 2024 年 12 月 21 日 上午 4:18 
Hello, thank you for providing a new sample of ModOptions. It is very helpful. Previously, with the Mod Options Mod, it was possible to hook into the OnApplyInGame function to perform some processing when settings were changed. Is it possible to achieve the same functionality with the ModOptions in Build 42?
Nepenthe 2024 年 12 月 20 日 上午 7:08 
Thanks, this is a helpful way to show the options.
Kyu 2024 年 12 月 20 日 上午 2:51 
@dhert - Thanks for checking! I decided to go with changing to booting of my mod to when the save loads. This was super helpful and I credited you in my B42 mod. You rock!
Slayer 2024 年 12 月 19 日 下午 11:46 
Just wanted to say that this was very helpful. Thank you!
dhert  [作者] 2024 年 12 月 19 日 下午 11:06 
There are no additional parameters, its just PZAPI.ModOptions:load().
The settings are loaded as part of the GameBoot, you're correct (specifically when the MainScreen's object is created).
That said, instead of calling load yourself and reading your options immediately after creating them, I would recommend adding an OnGameBoot function of your own to parse the values and set any local variables you need. Or, you can wait until OnGameStart since most options are typically unused until you start the game anyways.
I think it's probably best that all mods have a chance to load and create their options first, before the mod options load is performed.
Kyu 2024 年 12 月 19 日 下午 9:49 
Hey, Dhert! I was looking into this and found that the mod options are not loaded until sometime after the "OnGameBoot" event. I was poking around and saw PZAPI.ModOptions:load() and figured I could maybe force a load earlier in the process but I'm not sure what parameters that method is expecting. Any ideas?
dhert  [作者] 2024 年 12 月 19 日 下午 2:09 
Ha. I thought I mentioned that in some of the comments and tooltips.
But yea, for most of them its just "option:getValue()"
You don't have to store all of the configs like I did either. You can get your "options" table anytime via:
local options = PZAPI.ModOptions:getOptions("UNIQUEID")

Then get your individual options with:
local option = options:getOption("OptionID")
Tchernobill 2024 年 12 月 19 日 下午 1:40 
ok, for most of it, it is config.option:getValue()But
You you let me think Dhert.. it was supposed to be YOUR job, not mine :steammocking:
Tchernobill 2024 年 12 月 19 日 下午 1:37 
Did I missed it or the way to extract the config option value at runtime is not described ?
I think the way to get the option object is, but how do we extract something from it ?
Mxswat The Helldriver 2024 年 12 月 18 日 下午 4:45 
You deserve a lot of good things and happy holidays <3
poopie pants 2024 年 12 月 18 日 下午 12:58 
Awesome!
Tchernobill 2024 年 12 月 18 日 下午 12:51 
you're precious