Support_Preferences :: Development ceased until further notice

Author Topic: Support_Preferences :: Development ceased until further notice  (Read 3245 times)


    Probably doesn't need much of an introduction. :P



    BranchDownload
    StableN/A
    Unstable        http://parrokeet.duckdns.org/blockland/repo/Support_Preferences/unstable/Support_Preferences.zip




    API FUNCTIONS
    registerPref(%category,%name,%type,%variable,%default_value,%hide,%callback,%arguments);

    %categoryDefines in what list this pref shows up in, e.g. "General", "Admins", etc. It will appear in the list on the left.
    %nameDefines what the player will see beside inputs, e.g. "Admin Password", "Falling Damage", etc.
    %typeDefines what type the variable is. See below for the list of types.
    %variableThe affected variable.
    %default_value        The default value if nothing is set for the variable.
    %hideIf 0, update messages are allowed. If 1, they're always hidden. Useful for passwords.
    %callbackCommand to call when the variable updates.
    %argumentsArguments for the called command.

    TYPES
    • num [min] [max]
      • A number type. [min] is the lowest allowed amount, [max] is the highest.
      • registerPref("Samples","Sample Number Pref","num 0 100000","$NumberTest",24,0);

    • bool
      • True or false. 0 is false, 1 is true.
      • registerPref("Samples","Sample Bool Pref","bool","$BoolTest",1,0);

    • string [max characters]
      • A string type. [max characters] is the maximum allowed length of the string.
      • registerPref("Samples","Sample String Pref","string 255","$StringTest","TBP was here :O",0);

    • list TAB [value] [name in list] TAB [value 2] [name in list 2] TAB [value 3] [name in list 3]...
      • A dropdown list type. More than 2 types can be defined.
      • registerPref("Samples","Sample List Pref","list" TAB "1 Lowest value" TAB "2 A bit higher..." TAB "74 stupidly high cya","$ListTest",2,0);

    CALLBACKS
    Using callbacks is extremely simple and straightforward.

    In this example, we'll create a sample pref and use messageAll as the callback.
    • registerPref("Samples","Sample String w/ Callback","string 255","$CallbackTest","",0,"messageAll","\'MsgAdminForce\',$CallbackTest");

    After the %hide variable (0), you see "messageAll","\'MsgAdminForce\',$CallbackTest".
    "messageAll" is the called command, and "\'MsgAdminForce\',$CallbackTest" are the arguments sent to it. $CallbackTest is what we entered when changing the variable, \'MsgAdminForce\' simply plays a sound.

    Upon changing the sample pref, messageAll('MsgAdminForce',$CallbackTest); is called.



    Todo:

    - Legacy RTB support
    added in v0.6.0-dev-5
    "stable" in v0.6.0-dev-8

    Quote
    Port: needs callbacks
    »TheBlackParrot«: callbacks as in
    Port: being able to specify a function to call when the pref is changed
    added in v0.7.0-dev-2
    "stable" in v0.7.0-dev-5 *updated API

    - Option to hide messages even if checked when registering prefs
    added in v0.7.0-dev-2
    "stable" in v0.7.0-dev-5 *updated API

    - Slider type



    KNOWN ISSUES:
    • "Use RTB" shows up in the Start Game menu after first use, even with those that do not have RTB. (I'm assuming this check in BL's code may be dropped sooner or later, so I'm contemplating even doing anything about it)

    KNOWN ISSUES I CANNOT FIX:
    Duplorcator only shows it's prefs on the 1st created server. Because of the way it's coded, there is nothing I can do about this.
    It sets $Duplorcator::PrefsLoaded to true upon the first created server, and it never sets the variable back to false upon the server closing.
    One way you could work around it is by going into the bottom of server.cs in Tool_Duplorcator.zip, and add the following above line 1252 (it's a line with only };)
    [/list]
    Code: [Select]
    function onServerDestroyed()
    {
    $Duplorcator::PrefsLoaded = 0;
    parent::onServerDestroyed();
    }


      forget [/list]
      « Last Edit: May 19, 2014, 03:39:43 PM by TheBlackParrot »

      I can't download to try it out right now, but the Admin / SA password shouldn't be displayed even if the show update message is checked.
      I don't believe the RTB pref's did it, and it makes sense, since you would give the password to the people who needs it, not the whole server.

      I can't download to try it out right now, but the Admin / SA password shouldn't be displayed even if the show update message is checked.
      I don't believe the RTB pref's did it, and it makes sense, since you would give the password to the people who needs it, not the whole server.
      noted.

      hm.
      RTB_registerPref becomes a function when you start a server, even with default addons.

      I really don't want this to conflict with it, but it looks more and more like it will have to.



      when tracing the function using
      RTB_registerPref("Admin Only", "Duplorcator", "Pref::Duplorcator::AdminOnly", "bool", "Tool_Duplicator", 0, 0, 0);

      Duplorcator is not in my Addons folder rn

      Code: [Select]
      ==>trace(1);
         Console trace is on.
      Leaving ConsoleEntry::eval() - return
      Entering ConsoleEntry::eval()
         ==>RTB_registerPref("Admin Only", "Duplorcator", "Pref::Duplorcator::AdminOnly", "bool", "Tool_Duplicator", 0, 0, 0);
         Entering RTB_registerPref(Admin Only, Duplorcator, Pref::Duplorcator::AdminOnly, bool, Tool_Duplicator, 0, 0, 0)
         Leaving RTB_registerPref() - return 0
      Leaving ConsoleEntry::eval() - return
      Entering ConsoleEntry::eval()
         ==>trace(0);

      Why are you trying to trace it? Just take a look at the .cs; System_ReturnToBlockland/hooks/serverControl.cs. I would put the function in a code block here, but its pretty big, and i don't want to make your topic look untidy.

      Edit: It looks like it should never return 0 without echoing an error.
      « Last Edit: May 08, 2014, 06:32:45 AM by boodals 2 »

      For the list type. Will it return the string or the number?

      Edit: I'm dumb, you probably were asking about this add-on, not RTB.. Derp.

      For the list type. Will it return the string or the number?
      Number

      Added some well-needed things.
      I'm not sure if this still works alongside RTB, I believe it defaults to using RTB (if it actually exists) the way I coded it.

      System_ReturnToBlockland is also created if it doesn't exist. That's just to wrap RTB_registerPref back to my registerPref command and to trick RTB supported addons into thinking it exists.

      awwwwwww yeeeeeeEEEEEAAAAAAAAAHHHHHHHH

      I can't download to try it out right now, but the Admin / SA password shouldn't be displayed even if the show update message is checked.
      I don't believe the RTB pref's did it, and it makes sense, since you would give the password to the people who needs it, not the whole server.

      On this subject, RTB had the change messages registered along with the options:

      Code: [Select]
      RTBSC_registerServerOption("Server Name","string 150","$Server::Name","","The %1 has been changed to %2");
      RTBSC_registerServerOption("Welcome Message","string 255","$Server::WelcomeMessage","","The %1 has been changed to %2");
      RTBSC_registerServerOption("Max Players","playerlist 1 99","$Pref::Server::MaxPlayers","","The %1 has been changed to %2");
      RTBSC_registerServerOption("Server Password","string 30","$Pref::Server::Password","","The %1 has been changed");
      RTBSC_registerServerOption("Admin Password","string 30","$Pref::Server::AdminPassword","","The %1 has been changed");
      RTBSC_registerServerOption("Super Admin Password","string 30","$Pref::Server::SuperAdminPassword","","The %1 has been changed");
      RTBSC_registerServerOption("E-Tard Filter","bool","$Pref::Server::EtardFilter","","The %1 has been turned %2");
      RTBSC_registerServerOption("E-Tard Words","string 255","$Pref::Server::EtardList","","The %1 have been changed to %2");
      RTBSC_registerServerOption("Max Bricks per Second","int 0 999","$Server::MaxBricksPerSecond","","The %1 is now %2");
      RTBSC_registerServerOption("Falling Damage","bool","$Pref::Server::FallingDamage","","%1 has been turned %2");
      RTBSC_registerServerOption("Too Far Distance","int 0 9999","$Pref::Server::TooFarDistance","","The %1 has been changed to %2");
      RTBSC_registerServerOption("Admin Only Wrench Events","bool","$Server::WrenchEventsAdminOnly","","%1 have been turned %2");
      RTBSC_registerServerOption("Brick Ownership Decay","int -1 99999","$Pref::Server::BrickPublicDomainTimeout","","%1 has been changed to %2");

      So you can see next to Server Password, Admin Password, and Super Admin Password, there's no "to %2"
      You don't use strings per option but maybe just add a bool registered on whether to show the value or not?

      EDIT: Oops didn't see %hide :> But that looks like it doesn't show it at all, where RTB still says it changed.
      « Last Edit: May 08, 2014, 06:58:38 PM by Truce »

      On this subject, RTB had the change messages registered along with the options:
      -snip-
      So you can see next to Server Password, Admin Password, and Super Admin Password, there's no "to %2"
      You don't use strings per option but maybe just add a bool registered on whether to show the value or not?
      I may add in a 3rd value on %hide to only show the changed variable, but not the value.

      EDIT: Probably 0 for completely hidden, 1 for variable only, and 2 for both variable/value

      EDIT: Oops didn't see %hide :> But that looks like it doesn't show it at all, where RTB still says it changed.
      I decided not to show it at all, because I find it annoying when players start doing things just because a value (e.g. etard list) changed.

      But of course, there'll be an option to display only the changed variable soon.