--[[ OPTION DEFINITION FILES MapOptions.lua - belongs in the map archive - options that get used by LuaGaia ModOptions.lua - belongs in the mod archive - options that get used by LuaRules --]] --[[ NEW PROTOCOL MESSAGE SETSCRIPTTAG Examples: SETSCRIPTTAG GAME\MAPOPTIONS\GAIAUNITS 100 SETSCRIPTTAG GAME\MAPOPTIONS\DYNAMICRESOURCES 1 SETSCRIPTTAG GAME\MAPOPTIONS\EASTEREGGS 25 SETSCRIPTTAG GAME\MAPOPTIONS\PRECIPITATION snow SETSCRIPTTAG GAME\MODOPTIONS\DEPLOYMENT 1 SETSCRIPTTAG GAME\MODOPTIONS\SOFTSELFD 1 SETSCRIPTTAG GAME\MODOPTIONS\SHAREQUEUED 1 SETSCRIPTTAG GAME\MODOPTIONS\NOSHARING 0 SETSCRIPTTAG GAME\MODOPTIONS\AIBONUS 1.4142136 ??? -- check with tvo/beta --]] --[[ UNITSYNC INTERFACE enum OptionType { opt_error = 0, opt_bool = 1, opt_list = 2, opt_number = 3, opt_string = 4 }; int GetMapOptionCount(); // loads the map custom options int GetModOptionCount(); // loads the mod custom options const char* GetOptionKey(int optIndex); // keyg used by the script const char* GetOptionName(int optIndex); // display name const char* GetOptionDesc(int optIndex); // description (for tooltips?) int GetOptionType(int optIndex); // option type, see OptionType int GetOptionBoolDef(int optIndex); // default value (0 | 1) float GetOptionNumberDef(int optIndex); // default value float GetOptionNumberMin(int optIndex); // minimum value float GetOptionNumberMax(int optIndex); // maximum value float GetOptionNumberStep(int optIndex); // aligned to the def value const char* GetOptionStringDef(int optIndex); // default value for string int GetOptionStringMaxLen(int optIndex); // maximum visible chars int GetOptionListCount(int optIndex); // list items count const char* GetOptionListDef(int optIndex); // default item key const char* GetOptionListItemName(int optIndex, int itemIndex); // display name const char* GetOptionListItemDesc(int optIndex, int itemIndex); // description --]] -- Custom Options Definition Table format -- NOTES: -- - using an enumerated table lets you specify the options order -- -- These keywords must be lowercase for LuaParser to read them. -- -- key: the string used in the script.txt -- name: the displayed name -- desc: the description (could be used as a tooltip) -- type: the option type -- def: the default value; -- min: minimum value for number options -- max: maximum value for number options -- step: quantization step, aligned to the def value -- maxlen: the maximum string length for string options -- items: array of item strings for list options -- scope: 'all', 'player', 'team', 'allyteam' <<< not supported yet >>> -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- -- Example ModOptions.lua -- local options = { { key = 'deployment', name = 'Deployment Mode (MapOptions)', desc = 'Players deploy a limited number of units before the game starts', type = 'bool', def = false, }, { key = 'ai_bonus', name = 'AI Bonus', desc = 'Higher numbers mean that the AI gets more resources, health, etc...', type = 'number', def = 1.25, min = 0.25, max = 10, step = 0.05, -- quantization is aligned to the def value -- (step <= 0) means that there is no quantization }, { key = 'string_opt', name = 'String Option', desc = 'an unused string option', type = 'string', def = 'BiteMe', maxlen = 12, }, { key = 'selfd', name = 'SelfD Limit', desc = 'Limit the way that selfd can be used', type = 'list', def = 'NeverXXX', items = { { key = 'none', name = 'None', desc = 'Do not limit selfd' }, { key = 'time', name = 'Time', desc = 'Only 1 selfd command per game second is allowed' }, { key = 'never', name = 'Never', desc = 'SelfD can never be used' }, }, }, { key = 'list_test', name = 'List Test', desc = 'List Test Option', type = 'list', def = 'opt1', items = { 'opt1', 'opt2', 'opt3', 'opt4' }, }, } return options