Poll

What kind of server preference API would you prefer?

Straight-up RTB-like $Pref::* mappings
13 (65%)
Getters and setters (with type safety) to namespaced pref strings ("myaddon.foo.bar.somepref")
4 (20%)
Schema-based, supporting maps and arrays
3 (15%)
Something else (please post it)
0 (0%)

Total Members Voted: 20

Author Topic: BAM Poll: Type safety with server preferences  (Read 1662 times)

See the poll.

Here's an example of what the third option might look like:

new ScriptObject(MyAddonPrefs) // consistent object providing get/set access to actual values
{                              // TODO: how to represent names and descriptions in a friendly way?
    class = "BAMPrefs";        // magic happens in BAMPrefs::onAdd

    rules = new ScriptGroup()  // this is an array
    {
        // .type describes the type of each value in an array
        type = new ScriptObject() // this is a mapping
        {
            text = string;    // each of these defines the type of a property
            highlight = bool; // either could be set to a ScriptGroup/ScriptObject to use an array/a map
        };
    };

    mustAccept = bool;
    titleOfBox = string;

    // Maybe something like this for names, descriptions and defaults:
    // titleOfBox = new ScriptObject()
    // {
    //     type = string; // set to ScriptObject for map and ScriptGroup for array
    //     name = "Title of box";
    //     summary = "The text to use for the window title of the popup";
    //     default = "Server Rules";
    // };
};

// .get() yields the actual user-provided value of the pref
echo(MyAddonPrefs.get("titleOfBox"));
%rules = MyAddonPrefs.get("rules");

for (%i = 0; %i < %rules.getCount(); %i++)
    echo(%i + 1 @ ". " @ %rules.getObject(%i).get("text"));

this is still being worked on? holy stuff

Yeah, mainly Web Stuff

We'll create a development topic when we have more to show.
« Last Edit: December 08, 2014, 12:29:05 PM by chrisbot6 »

Seems like people are relatively afraid of change. How about implementing $Pref::* wrappers through BAM_addLegacyPref and namespaced prefs (serverrules.general.mustaccept) through BAM_addPref?

Seems like people are relatively afraid of change. How about implementing $Pref::* wrappers through BAM_addLegacyPref and namespaced prefs (serverrules.general.mustaccept) through BAM_addPref?
Liking.

One thing that would be cool is if the GUI was to organize prefs into categories and subcategories via expandable lists of some kind.

I would vote if I knew what a server preference API was...also what does the code in the op do?

Lol I probs shouldn't be in this thread

what does the code in the op do?
Creates a non physical object with information and another non physical object inside of it that stores more information. It's an example of how the third option in the poll would work. It's the best option because it's(in my opinion) the most flexible.

As long as it's intuitive and easy to use.
Also, could you not throw around advanced terminology like we would understand? Because most of us don't..

As long as it's intuitive and easy to use.
Also, could you not throw around advanced terminology like we would understand? Because most of us don't..
I think the poll is mostly for knowledgable scripters. As it's only going to be scripters using it.

I think the poll is mostly for knowledgable scripters. As it's only going to be scripters using it.
If the system isn't easy to learn and use, it might discourage newbie scripters from making mods that are compatible with BAM.

If the system isn't easy to learn and use, it might discourage newbie scripters from making mods that are compatible with BAM.
Maybe make two ways to make prefs? A simple way for less knowledgable scripters and a more complex and flexible way for the more knowledgable scripts that want to make a more complex pref that can't be done with the simple way?

I think the poll is mostly for knowledgable scripters. As it's only going to be scripters using it.

That's a setup for disaster...