-
Notifications
You must be signed in to change notification settings - Fork 157
Commands
Self-commands are commands that you enter from the game that are explicitly intended for your GearSwap files, and not the game itself. My include libraries use a number of them to maintain state and adjust configuration.
These commands are sent from the game in one of three ways:
-
gs c <command>
- Use this if you're entering a command directly in the Windower console, or from a keybind. -
//gs c <command>
- Use this if you're entering a command from the chat line. -
/console gs c <command>
- Use this if you're entering a command from an in-game macro.
<command>
represents the entire string that is sent to your script. //gs c where is waldo?
would send the string "where is waldo?"
to your script.
However my include will break that string up into individual words. Any time that the <command>
string is passed to user code, it will actually be a table of the individual words passed in. In the above example, that would be {"where", "is", "waldo?"}
.
Before handling things on the include side, a call is made to job_self_command(commandArgs, eventArgs)
. Setting eventArgs.handled
to true will prevent the default include code from running.
Mote-Globals.lua defines a default set of commands that are bound to the F9 through F12 keys. These defaults can be overridden in a User-Globals file, if desired. The default binds are:
-
F9
- Cycle Offense Mode (the offensive half of all 'hybrid' melee modes). -
Ctrl-F9
- Cycle Hybrid Mode (the defensive half of all 'hybrid' melee modes). -
Alt-F9
- Cycle Ranged Mode. -
Win-F9
- Cycle Weaponskill Mode. -
F10
- Activate emergency Physical Defense Mode. Replaces Magical Defense Mode, if that was active. -
F11
- Activate emergency Magical Defense Mode. Replaces Physical Defense Mode, if that was active. -
Ctrl-F10
- Cycle type of Physical Defense Mode in use. -
Alt-F12
- Turns off any emergency defense mode. -
Alt-F10
- Toggles Kiting Mode. -
Ctrl-F11
- Cycle Casting Mode. -
F12
- Update currently equipped gear, and report current status. -
Ctrl-F12
- Cycle Idle Mode.
'State' is a term to describe your current configuration. It encompasses a wide variety of variables that are used throughout the code to determine how things are supposed to behave.
There are generally several ways to manipulate the value of each state variable, depending on what type of state it represents. This allows a certain amount of flexibility in exactly how you want to set up your gaming environment.
There are three general types of state variables:
- String variables. String variables are simple string values. They may not be set to nil.
- Boolean variables. Boolean variables may only be set to true or false.
- List variables. List variables may be set only to one of a fixed number of predefined values.
State variables are all stored in the state
table. For example, the current Offense Mode is kept in the state.OffenseMode
variable.
State variables are created from the Modes
class (using the M
constructor), and hold information about what type they are, and what values are valid for each one (particularly the list version). Commands to change the variable value are intrinsic to the class, and should be applied using the :
(colon) operator. For example: state.OffenseMode:set('Acc')
.
There are a few different types of commands for changing state. Each is used as the first word of the <command>
given as a self-command.
-
toggle
- The Toggle command can be used to change a value between true and false. Only valid for boolean state variables. -
cycle
- This cycles through the list of available option values for an list state variable. When it reaches the end of the list, it starts over at the beginning. For boolean variables, this is the same astoggle
. It can't be used on string variables. -
cycleback
- This is the same ascycle
, except that it moves backwards through the available list values. -
set
- This allows you to set a state variable to any value. On/off/true/false can be used for boolean state variables. Any valid list value can be used for list state variables (case-sensitive). Any string is valid for string state variables.:set()
by itself (with no parameters) on a boolean variable will set it to true. -
reset
- This resets a variable back to its default state. The default value for a variable is set during its initial construction. [See: Mode variables] -
unset
- This returns a boolean or string variable to a blank state. Boolean variables are set to false, and strings are set to an empty string.
The overall syntax for a command is like this:
gs c set OffenseMode Acc
Resetting
reset
has an optional value it can take, rather than the state variable name: all
. This will reset all state variables that are directly attatched to the state
table. Thus: state.OffenseMode
, state.HybridMode
, etc., but not anything in the state.Buff
table.
This is a list of globally valid state types.
List types
- OffenseMode (melee offense set selection)
- HybridMode (melee hybrid set selection)
- RangedMode (ranged attack set selection)
- WeaponskillMode (weaponskill set selection)
- CastingMode (casting set selection)
- IdleMode (idle set selection)
- RestingMode (resting set selection)
- PCTargetMode (PC targetting adjustment option)
Boolean types
- Kiting (whether to apply a kiting set atop other gear)
- SelectNPCTargets (whether to adjust targets to )
String types
- CombatForm (melee or ranged set selection based on a general 'form')
- CombatWeapon (melee or ranged set selection based on weapon)
Emergency defense states are maintained in several mode variables:
- DefenseMode (list: None, Physical or Magical)
- PhysicalDefenseMode (specific set selection for physical defense)
- MagicalDefenseMode (specific set selection for magical defense)
In addition, there is a state.Buff
table that can be used to track the state of character buffs in a semi-automated manner. Any action a user takes that has a name matching a defined buff in the state.Buff table is tracked based on precast/aftercast results, which makes it more accurate than waiting on buff_change notifications.
In addition to the global state variables, the user can set things up to allow these same commands to be used to modify their own user state variables.
Each of the commands above (toggle, cycle, reset, etc) will try to call user functions of the appropriate type if they are unable to identify a global state variable to modify.
job_state_change(descriptor, new_value, old_value)
Any time a state variable that the include automatically handles (ie: not something adjusted by the job_ function calls) is changed, the job file is notified via a call to job_state_change
. The descriptor
parameter uses the ['description']
value of the mode variable, if available, or the state field name if not.