PDA

View Full Version : Options subsystem



Varsuuk
March 17th, 2019, 03:23
Is there a place where using this is described? If so, link that so I can read in case it answers all I want to know ;)

But in the event it isn't so I can get ahead of the game:

I am trying to setup an option for my ruleset where you have a choice of default or categories style saving throws. As usual, I looked in 5E and AD&D rulesets for clues.

From Celestian's work of AD&D goodness:


OptionsManager.registerOption2("HouseRule_CRIT_TYPE", false, "option_header_houserule", "option_label_HR_CRIT", "option_entry_cycler",
{ labels = "option_val_hr_crit_maxdmg|option_val_hr_crit_times two|option_val_hr_crit_none", values = "max|timestwo|none", baselabel = "option_val_hr_crit_doubledice", baseval = "doubledice", default = "doubledice" });


So I started by doing


OptionsManager.registerOption2("HR_SAVES", false, "option_header_houserules", "option_label_HR_SAVES",
"option_entry_cycler",
{ labels = "option_val_hr_default|option_val_hr_categories", values = "default|categories",
--> Left off here, wondered what to put here: baselabel = "option_val_hr_crit_doubledice", baseval = "doubledice", default = "doubledice" });



I am confused about baselabel. In the AD&D case it appears to be an option for double-dice, but I do not see that in the option_val labels or values entries preceding baselabel.
default is the baseball of double dice.

Is baselabel options described somewhere? I figure I need to put
default = "default" to select my default (sorry) option which is named "default" ;)

Just lost on integrating my understanding with baselabel and baseval and ASSUME I "got" default at end.

Varsuuk
March 17th, 2019, 04:05
This "works" - but still not sure what "base_" keys are for.



OptionsManager.registerOption2("HR_SAVES", false, "option_header_houserules", "option_label_HR_SAVES",
"option_entry_cycler",
{ labels = "option_val_hr_default|option_val_hr_categories", values = "default|categories",
baselabel = "option_val_hr_default", baseval = "categories", default = "categories" });

gamerhawaii
March 17th, 2019, 04:49
I believe those are the references to the strings to display. That is, put the string to display for each option in strings_utility.xml (or could be one of the other strings_xxx.xml files.) As another example, look at data_options_core.lua and you will see the same format. And those references are to the strings displayed in the options tool.

(I am not positive on that. That is just what it looks like to me. I have not actually tried it out to be sure.)

Varsuuk
March 17th, 2019, 05:52
Well still confused as putting default=categories on a new campaign still shows in the options window "Single" (which is the value associated with "val_hr_default ) so my initial guess of what default is for is shot ;)

So if BASEVAL is really the "shown at startup" value, what is default= for?

gamerhawaii
March 17th, 2019, 06:23
Use the 5E options as your example since they are documented. Look at manager_options.lua from Core ruleset, and then data_options_5e.lua & strings_5e.xml from 5E ruleset as examples. This page shows you what they mean: https://www.fantasygrounds.com/wiki/index.php/5E_Options.

If you look at those items, you should be able to figure it out.

(Seems like default is the default choice, and baseval seems to be another option)

Varsuuk
March 17th, 2019, 16:04
I was hopeful when you said 5E was documented, you meant the option choices - but those I figured out to the extent needed simply by looking up the string resources. So, I dove into the code.
(I posted the question hoping someone knew so I could be lazy 'cos I got it working as I wanted, it just seemed counterintuitive from MY interpretation)

default is referenced in CoreRPG manager_options
baseval is not referenced in that code. It is in utility_options. There I see it is used in "option_entry_cycler" as the default value to be used if not null and empty string otherwise. If the retrieved option is equal to it... the retrieved option is blanked out. No clue.

The answer is in the code for button cycler and I just don't care ;) it's too early. It currently "works" when I hav the code that will read the options written, I will mess with changing those args and infer what how they customize things. I really don't need to know how the internals do it - I don't have time to write what I am writing and this form of coding with controls/xml ;) makes my eyes swim at time (did I mention I haven't touched a UI since 6 months in early 90's on Windows using Visual Studio 1.52? (16bit).) All my work is on servers and using messaging.

Anyhow, seeing how controls are written IS interesting to me, but I have to prioritize and getting the ruleset to a simple usable state is first one. I just needed an option (more to follow) and it seems I got how to do that by copying even if I do not understand the relationship between "baseval" and "default" properly yet.