Gaming
 

KhaosOption

From WoWWiki

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

	KhaosOption =  {
		id = "ModOptionId"; -- Unique within the Set
		key = "SharedDataKey"; -- Can be shared within the set [radio buttons]
		value = 5;
		text = "Some Uber Feature";
		difficulty = 2;
		helptext = "Some long description of what this option does";
		callback = function(state) Sea.io.printComma(state.checked, state.value, state.button, state.slider); end;
		feedback = function(state) 
			if ( state.checked ) then 
				return "Uber feature is enabled at "..state.slider.." percent.";
			else
				return "Uber feature is disabled.";
			end
		end;
		check = boolean; 
		radio = boolean;
		type = K_TEXT|K_BUTTON|K_SLIDER|K_PULLDOWN|K_EDITBOX|K_HEADER;
		setup = {
			-- radio
			selectedColor = {r=0,g=1,b=0};
			disabledColor = {r=1,g=0,b=0};
			
			-- If button
			buttonText = "Click Here";

			-- If slider
			sliderMin = 0;
			sliderMax = 1;
			sliderStep = .1;
			sliderSignificantDigits = 2;
			sliderText = "Choose a % from 0-1";
			sliderLow = "Lowest";
			sliderHigh = "Highest";
			sliderDisplayFunc = function ( value ) return (math.floor(slidervalue*100)/100).."%";  end; 

			-- If pulldown
			options = {
				["Foo"] = 1,
				["Bar"] = 2,
				["Baz"] = "mew"
			};
			multiSelect=true;    

			-- If editbox
			callOn = { 
				-- Call when the user types a space
				"space", 
				-- Call when the box is selected
				"focus", 
				-- Call when the box is deselected
				"unfocus", 
				-- Call when the user hits escape
				"escape", 
				-- Call when the user hits tab
				"tab", 
				-- Call when the user changes the text
				"change", 
				-- Call when the user hits enter or selects something else
				"set", 
				-- Call on all of these things
				"all" 
			}; 
			multiLine=true; -- Use a popup multi-line scrollable editbox. Only uses the "accept" callOn.

			-- If colorpicker
			hasOpacity = true; -- If you want to show an opacity slider			
			
		};
		default = {
			checked = true;
			slider = .5;  

			-- For color picker only
	 		color = { r=1.0, g=.5, b=.24, opacity=1 };
		};
		disabled = {
			checked = false;
			slider = .0;
			
			color = { r=1.0, g=1.0, b=1.0, opacity=.5 };
		};
		dependencies = {
			["key"] = { value=3; match=true; checked=false }; 
			["key2"] = { value=3; match=false; }; 
		};
	}

  • id - unique value (within the current set) for this specific option. used to modify the option later
  • key - string id for the key which will hold data related to this option (can be shared between radio types)
  • value - value of key.value when the check/radio is clicked
  • difficulty - difficulty of the configuration (1 = beginner, 3 = advanced, 4 debug)
  • text - string - short text displayed
  • helptext - long description of what this option will do when set
  • callback - function called when the option is modified.
    • (state, keypressed)
    • state - the new state due to user input
    • keypressed - editbox only, tells you the key that triggered the callback
  • feedback - function that is called whenever the state changes
    • it should return a string that describes the current state
    • of the option. This will be used for the newbie interface.
    • Same arguments as callback.
  • check - true - show the check
    • If radio is true, check = true means the radio can be unchecked
    • false - dont show the check
  • radio -
    • true - will be unchecked if the folder[key]'s value doesnt match your value
    • false - will only uncheck if clicked.
  • type - the main type of this node
    • K_TEXT - text only
    • K_BUTTON - push to call callback with state
    • K_SLIDER - a variable slider which callback on changes
    • K_EDITBOX - an edit box which does callback on the specified events
    • K_PULLDOWN - a menu which callback when you select options
    • K_HEADER - a string separator which displays a text bit
  • setup - table which varies depending on type
    • K_TEXT - nothing
    • K_BUTTON -
      • buttonText - text for the button
    • K_SLIDER -
      • sliderMin - min value of slider
      • sliderMax - max value of slider
      • sliderLow - low text string
      • sliderHigh - high text string
      • sliderSignificantDigits - number of decimal places perserved (default 2)
      • sliderStep - increment between for slider
      • sliderText - text over the slider
      • sliderDisplayFunc - function used to generate slider text
    • K_EDITBOX -
      • callOn - list of events that trigger callbacks (tab, space, enter, escape)
      • multiLine - Use a popup multi-line scrollable editbox. Only uses the "accept" callOn.
    • K_PULLDOWN -
      • options - table of key-value pairs the user can pick from
      • multiSelect - if true, multiple values can be selected
    • K_COLORPICKER
      • hasOpacity - true if it has an opacity slider
    • K_HEADER - nothing
  • default - the default state of the option's key
    • value - value of the key
    • checked - true if checked, false if not
    • slider - value of the slider
    • color - color of the colorpicker
  • disabled - the state of the key when the config set is disabled
    • (same properties as default)
  • dependencies - key based dependencies which will be checked. If any are false, the Option is disabled
    • value - the value the key will be tested against
    • checked - the checked state the key will be tested against
    • match -
      • true - the dependency will be true if key's value equals dependency value
      • false - the dependency will be true if the key's value is not equal to the dependency's value