PDA

View Full Version : example of adding a number field to the options window in the combat section



rmilmine
March 7th, 2026, 20:04
Can someone give me a place to find an example of how to add an option to the options window in the combat section?
Something that shows how to access it would be great as well.

Thanks,
Robert.

rmilmine
March 8th, 2026, 16:51
After giving up finding anything that works using a search as it all showed doing xml and lua code that didn't work.
So I went into an extension that I know has options and found the code that made them show up and how to access them.

So to make an options show up you need to create a lua file and use <script name="" file="" /> in the base.xml or extension.xml file.



<script name="XCoreDataOptions" file="scripts/XCoreDataOptions.lua" />


Then in that file you need to add to onInit() ad the following:



function onInit()
OptionsManager.registerOption2("XCORE_CT5", false, "option_header_combat", "option_label_CT5", "option_entry_number", {});
end


"XCORE_CT5" is the unique identifier that will be used to access the value that is in the option.

false notes if it is to be displayed on the client and host or just host.
"option_header_combat" is the section in the options where the item willl be displayed.

"option_label_CT5" is a string name that is used to get the label.

"option_entry_number" is the name of what type of data it is, "option_entry_cycler" is also available and has lots of options.

{} is for any options related to the item. for number there is { min=#, max=# } with # being replaced by actual numbers.

"option_label_CT5" is defined in a strings.xml file



<string name="option_label_CT5">Combat Tracker: Change Initiative by</string>


to retrieve the value for the option you need to do the following:



local nChangeInitBy = OptionsManager.getOption("XCORE_CT5");

LordEntrails
March 8th, 2026, 17:01
So this is over in the options button/menu on the right side?

rmilmine
March 8th, 2026, 17:10
So this is over in the options button/menu on the right side?

This is how it looks in the options window:

66762

rmilmine
March 8th, 2026, 17:13
Sorry yes it's the options in Tools section on the right.

rmilmine
March 8th, 2026, 17:25
After some testing, it appears the true/false parameter is not if it shows up in the client or host. I'm not sure what it does.

rmilmine
March 8th, 2026, 17:33
what I did to make it only show up on the host and not on the client was the following:



if User.isHost() then
OptionsManager.registerOption2("XCORE_CT5", true, "option_header_combat", "option_label_CT5", "option_entry_number", {});
end

LordEntrails
March 9th, 2026, 15:22
Thanks, I get it now. Wasn't sure at first. I haven't touched the options menu at all. Trying to think of a free extension that is not in the vault that does. Maybe NPC Flavors, Player Agency, or Safety Toolkit?

rmilmine
March 9th, 2026, 15:35
Kelrugem's extendes automation and overlays extension for 3.5 and pathfinder has several. There sre several others for pathfinder that do as well.

Moon Wizard
March 9th, 2026, 17:41
Here's a recent example for adding a numerical option:



OptionsManager.registerOptionData({
sKey = "TOKEN_SPEECH", bLocal = true, sGroupRes = "option_header_client_notify", sType = "option_entry_number",
tCustom = { min = 0, default = tostring(OverlayManager.DEFAULT_SPEECH_NOTIFY_DURA TION), },
});


For a campaign specific option, it would look more like:



OptionsManager.registerOptionData({ sKey = "XCORE_CT5", sGroupRes = "option_header_combat", sType = "option_entry_number", }, });


Regards,
JPG

rmilmine
March 9th, 2026, 18:26
Thank you for that.

rmilmine
March 9th, 2026, 19:22
Does bLocal = true/false have an impact on whether the option shows up on the host and/or client?
Do I need to do what I did with User.isHost()?

Moon Wizard
March 10th, 2026, 02:11
An option will always show on both host and client.

However, those with the bLocal flag indicate that they are per-user options, that can be set by each user local to their instance.

If you want an option that is per-campaign (ie controlled by GM only), then do not use the bLocal flag.

Regards,
JPG

rmilmine
March 10th, 2026, 02:23
Thank you.
I'll take that into account.