Gaming
 

Khaos/Configuration Example

From WoWWiki

This article is a part of the documentation of the Khaos function library

Khaos example

function KhaosConfig_RegisterDemo()
   Khaos.registerFolder( 
       {
           id = "bar";
           text = "Bars";
           helptext = "Optional Bars of Power";
           difficulty = 1;
       },
       {
           id = "classhelper";
           text = "Class Helpers";
           helptext = "Tools of immense power";
           difficulty = 2;
       },
       {
           id = "comm";
           text = "Communication";
           helptext = "Communication of many types";
           difficulty = 2;
       },
       {
           id = "quest";
           text = "Quests";
           helptext = "Quest affecting mods";
           difficulty = 2;
       },
       {
           id = "debug";
           text = "Debug Tools";
           helptext = "I love these";
           difficulty = 4;
       }
   );

   local radioTestCallback = function (state)
       if ( state.value == "green" ) then
           Sea.io.print("Bars are green!!");
       elseif ( state.value == "red" ) then
           Sea.io.print("Bars are red!");
       else
           Sea.io.print("Bars are some other color!");
       end
   end;
   local radioTestFeedback = function(state)
       if ( state.value == "green" ) then
           return "You have green bars.";
       elseif ( state.value == "red" ) then
           return "You have red bars.";
       else
           return "Your bars are "..state.value..".";
       end
   end;
   local radioTestDefault = {
       value = "green";
   };
   local radioTestDisabled = {
       value = "red";
   };
   local optionSet =
       {
           id="BlizzardBars";
           text="Blizzard Bars";
           helptext="Blizzard's Default Bars - Better!";
           difficulty=1;
           options = {
               {
                   id="BlizzBarHeader";
                   text="Blizzard Bar Location";
                   helptext="These options relocate the Blizzard bars to nicer locations.";
                   type = K_HEADER;
               };
               {
                   id="SwapBarRight";
                   text="Move Right Bar";
                   helptext="These options relocate the Blizzard right bars to nicer locations.";
                   type = K_TEXT;
                   key = "BlizSwapRight";
                   value = true;
                   check = true;
                   callback = function(state)
                       if ( state.checked ) then
                           Sea.io.print("Checked! Right Bars move to the left!");
                       else
                           Sea.io.print("Unchecked! Right Bars move to the original spot");
                       end
                   end;
                   feedback = function(state)
                       if ( state.checked ) then
                           return "Right Bars are attached to the left";
                       else
                           return "Right Bars are attached to the right";
                       end
                   end;
                   default = {
                       checked = true;
                   };
                   disabled = {
                       checked = false;
                   };
               };
               {

                   id="SwapBarLeft";
                   key="BlizSwapLeft";
                   value=true;
                   text="Move Left Bar";
                   helptext="Moves the left extra bar to the left side of the screen.";
                   type = K_SLIDER;
                   check = true;
                   setup = {
                       sliderMin = -50;
                       sliderMax = 100;
                       sliderLowText = "Top";
                       sliderHighText = "Bottom";
                       sliderStep = 10;
                       sliderText = "Vertical Offset";
                       sliderDisplayfunc = function (state) return state.slider; end;                        
                   };
                   callback = function(state)
                       if ( state.checked ) then
                           Sea.io.print("Checked! Bars move to the left!");
                       else
                           Sea.io.print("Unchecked! Bars move to the original spot");
                       end
                   end;
                   feedback = function(state)
                       if ( state.checked ) then
                           return "Bars are attached to the left";
                       else
                           return "Bars are attached to the right";
                       end
                   end;
                   default = {
                       checked = true;
                       slider = 10;
                   };
                   disabled = {
                       checked = false;
                       slider = 0;
                   };
                   dependencies = {
                       ["BlizSwapLeft"] = { checked=true; match=true;};
                   };
               };
               {
                   id="BlizzBarRadio1";
                   text="Green Colored Bars";
                   helptext="These options recolor";
                   key = "TestRadio";
                   value = "green";
                   radio = true;
                   type = K_TEXT;
                   default = radioTestDefault;
                   disabled = radioTestDisabled;
                   callback = radioTestCallback;
                   feedback = radioTestFeedback;
                   setup = { 
                       selectedColor={r=0,g=1,b=0};
                       disabledColor={r=.5,g=.5,b=.5};
                   }
               };
               --[[
               {
                   id="BlizzBarRadio2";
                   text="Red Colored Bars";
                   helptext="These options recolor";
                   key = "TestRadio";
                   value = "red";
                   radio = true;
                   type = K_TEXT;
                   default = radioTestDefault;
                   disabled = radioTestDisabled;
                   callback = radioTestCallback;
                   feedback = radioTestFeedback;
                   setup = { 
                       selectedColor={r=1,g=0,b=0};
                       disabledColor={r=.5,g=.5,b=.5};
                   }
               };
               ]]
               {
                   id="BlizzBarRadio2";
                   text="Blue Colored Bars";
                   helptext="These options recolor the bars";
                   key = "TestRadio";
                   value = "blue";
                   radio = true;
                   type = K_TEXT;
                   default = radioTestDefault;
                   disabled = radioTestDisabled;
                   callback = radioTestCallback;
                   feedback = radioTestFeedback;
                   setup = { 
                       selectedColor={r=.2,g=2,b=1};
                       disabledColor={r=.5,g=.5,b=.5};
                   }
               };
               {
                   id="BlizzardBarReset";
                   text="Clear all bars";
                   helptext="Will remove the action keys from all bars";
                   type = K_BUTTON;
                   callback = function()
                       Sea.io.print("You reset! All your bars were cleared.");
                   end;
                   setup = {
                       buttonText = "Clear";
                   };
               };
               {
                   id="BlizzardBarPulldown";
                   key="BBPulldowns";
                   text="Select Recolored Bar";
                   helptext="Select which bars you want affected by the recoloring";
                   type = K_PULLDOWN;
                   callback = function(state)
                       Sea.io.print("You've selected which bar will be affected!");
                   end;
                   feedback = function (state)
                       local vals = "";

                       for k,v in state.value do
                           vals = vals.." "..v;
                       end

                       return vals.." is selected.";
                   end;
                   setup = {
                       options={
                           ["Left Bar"] = "Left";
                           ["Right Bar"] = "Right";
                           ["Top Bar"] = "Top";
                           ["Bottom Bar"] = "Bottom";
                       };
                       multiSelect=false;
                   };
                   default = {
                       value = "Left";
                   };
                   disabled = {
                       value = nil;
                   };
               };
               {
                   id="BlizzardBarPulldown2";
                   key="BBPulldowns2";
                   text="Select Movable Bars";
                   helptext="Select which bars you want to move";
                   type = K_PULLDOWN;
                   callback = function(state)
                       Sea.io.printTable(state);
                       Sea.io.print("You've selected which bar will be affected!");
                   end;
                   feedback = function (state)
                       local vals = "";

                       for k,v in state.value do
                           vals = vals.." "..v;
                       end

                       return vals.." is selected.";
                   end;
                   setup = {
                       options={
                           ["Left Bar"] = "Left";
                           ["Right Bar"] = "Right";
                           ["Top Bar"] = "Top";
                           ["Bottom Bar"] = "Bottom";
                       };
                       multiSelect=true;
                   };
                   default = {
                       value = {"Left"};
                   };
                   disabled = {
                       value = {};
                   };
               };
               {
                   id="BlizzardBarCommand";
                   key="BBResetCommand";
                   value={"/bbreset"};
                   text="Enter reset slash command";
                   helptext="Pick your own slash command";
                   type = K_EDITBOX;
                   callback = function(state)
                       Sea.io.print("You've entered ", state.value);
                   end;
                   feedback = function (state)
                       return state.value.." will call the reset!";
                   end;
                   setup = {
                       callOn = {"enter"};
                   };
                   default = {
                       value = "/bbreset";
                   };
                   disabled = {
                       value = "/bbresetdisabled";
                   };
               };
               {
                   id="ZoneColor";
                   key="ZoneColor";
                   text="Zone Text Color";
                   helptext="Pick a color for the zone text";
                   type = K_COLORPICKER;
                   callback = function(state)
                       Sea.io.printc(state.color, "You've selected ", unpack(state.color) );
                   end;
                   feedback = function (state)
                       return "You've selected a color!";
                   end;
                   setup = {
                       hasOpacity = true;
                   };
                   default = {
                       color = { r=1, g=1, b=0, opacity=.6 };
                   };
                   disabled = {
                       color = { r=.8,g=.8,b=.8,opacity=.6 };
                   };
               };
           };
           default = true;
       };
   Khaos.registerOptionSet(
       "bar", optionSet
   );
-- or do it like:
   Khaos.registerOptionSet(
       "bar",
       {
           id="FlexBar";
           text="Flexbars";
           helptext="As flexible as you are";
           difficulty=3;
           options = {};
           default = false;
       }
   );
   Khaos.registerOptionSet(
       "bar",
       {
           id="PopBar";
           text="PopBars";
           helptext="They Pop when you click 'em";
           difficulty=2;
           options = {};
           default = false;            
       }
   );
   Khaos.registerOptionSet(
       "bar",
       {
           id = "2ndBar";
           text = "Second Bars";
           helptext="Easy Second Hand";
           difficulty = 1;
           options = {};
           default = true;
       }
   );

   Khaos.registerOptionSet(
       "classhelper",
       {
           id = "DivineBlessing";
           text = "Divine Blessing";
           helptext="Bless 'em all";
           difficulty = 3;
           options = {};
           default = false;
       }
   );
   Khaos.registerOptionSet(
       "classhelper",
       {
           id = "HealerHelper";
           text = "Healer Helper";
           helptext="Heal with the power of hotkeys";
           difficulty = 2;
           options = {};
           default = false;
       }
   );
   Khaos.registerOptionSet(
       "classhelper",
       {
           id = "RogueHelper";
           text = "Rogue Helper";
           helptext="Rogues do it from behind.";
           difficulty = 2;
           options = {};
           default = false;
       }
   );
   Khaos.registerOptionSet(
       "classhelper",
       {
           id = "ShardTracker";
           text = "Shard Tracker";
           helptext="Your soul is mine!";
           difficulty = 2;
           options = {};
           default = false;
       }
   );
   Khaos.registerOptionSet(
       "classhelper",
       {
           id = "TotemStomper";
           text = "Totem Stomper";
           helptext="Behold my fierce set!";
           difficulty = 3;
           options = {};
           default = false;
       }
   );
   
   -- Comm 
   Khaos.registerOptionSet(
       "comm",
       {
           id = "CombatCaller";
           text = "Combat Caller";
           helptext="Combat Time! Heal me!";
           difficulty = 1;
           options = {};
           default = true;
       }
   );
   Khaos.registerOptionSet(
       "comm",
       {
           id = "Pager";
           text = "Pager Power";
           helptext="STOP!!!!";
           difficulty = 2;
           options = {};
           default = true;
       }
   );
   Khaos.registerOptionSet(
       "comm",
       {
           id = "PetMon";
           text = "Pet Monitor";
           helptext="Displays a live frame on your pets health";
           difficulty = 2;
           options = {};
           default = true;
       }
   );
   Khaos.registerOptionSet(
       "comm",
       {
           id = "RaidMinion";
           text = "RaidMinion";
           helptext="See anyone anywhere anytime";
           difficulty = 3;
           options = {};
           default = true;
       }
   );

   -- Quests
   Khaos.registerOptionSet(
       "quest",
       {
           id = "PartyQuests";
           text = "PartyQuests";
           helptext="Who else has this quest?";
           difficulty = 1;
           options = {};
           default = true;
       }
   );

   Khaos.registerOptionSet(
       "quest",
       {
           id = "QuestMinion";
           text = "Quest Minion";
           helptext="How many items are left?";
           difficulty = 2;
           options = {};
           default = false;
       }
   );
   
   Khaos.registerOptionSet(
       "quest",
       {
           id = "QuestHelp";
           text = "QuestHelperr";
           helptext="Yarrrrr";
           difficulty = 3;
           options = {};
           default = false;
       }
   );
  Khaos.registerOptionSet(
       "debug",
       {
           id = "Fooz";
           text = "Foozz";
           helptext="Life is wasted";
           difficulty = 4;
           options = {};
       }
   );
end;