PDA

View Full Version : 5E extension options



jkeller
December 13th, 2025, 01:42
What is the "best practice" for how extensions should use options?

I generally try to register the option on the host, but I just realized the code that checks the option may be running on a client. So, if I want to have an on/off option to disable (or otherwise affect the behavior of my extension), do I need to always register the option (regardless of host or client)?

And if so, how do I protect it such that it can only be changed on the host?

And if it's changed on the host, is it changed on the clients too?

Thanks!

Moon Wizard
December 13th, 2025, 04:03
In general, I try to minimize options, and use the best case for the majority of users.
When I have to use an option, I decide whether it's for every user to decide, or whether it should be controlled by the GM/campaign.

There is a setting in the option registration to determine whether an option is Local (per user) or Campaign (GM-controlled only).

Ex: Local options: MANUALROLL, WSAV
Ex: Campaign options: REVL, TBOX

Regards,
JPG

jkeller
December 13th, 2025, 20:52
Thanks, that helped!

So for anyone who needs to do something similar, here's what I did:

1) In onInit, I register the options (host and client)
2) I use bLocal = false (probably the default); this lets the client see the option read-only. You can use true if you want to let the client change their local option.
3) I call OptionsManager.registerCallback to listen for option changes
4) In my listener, I register or unregister the handlers:



function onOptionChanged(nodeOption)
local sVal = OptionsManager.getOption(OPTION_KEY);
postMessage("Some Extension option updated => " .. tostring(sVal), true);
if sVal and sVal == "on" then
registerHandlers();
else
unregisterHandlers();
end
end


So as DM, I can turn the extension on or off.