## Macros

### General info

Macros are a way to send common messages without having to type all of the information you want to say every time. The 'Macros' tab will help you create macros that you can send by hitting your macro key ('X' is the default) and then the key you define. RCDs (Remote Configurable Distresses) are similar to macros and should be used if possible to send very common messages (see the RCD tab for more information).

### Modifying Macros

At the top of the 'Macros' tab is a table containing all of the macros that have been defined. Some examples have been given to give you an idea what macros are good for.

Clicking on a macro in the table will load the macro into the bottom portion of the tab. There are 3 parts to a macro.

1. Key
2. Send to
3. Macro

The Key is the key to use in conjunction with the macro key to send the macro. The Send to drop down list is the destination that the macro will go to. The choices are...

- Myself - Send the message to yourself
- Mouse: nearest player - Send the message to the player nearest to your mouse cursor
- Mouse: nearest player's team - Send the message to the team of the player nearest to your mouse cursor
- Ship: closest friendly player - Send the message to the nearest friendly player to your ship
- Ship: closest enemy player - Send the message to the closest enemy player to your ship
- Everyone - Send the message to everyone
- My team - Send the message to your team
- Determine when sending - Choose the destination when sending the message

The macro field is where you enter the text of the macro that you want to send. The text can be one line or multiple lines. You should be careful about having an extra line at the bottom of your macro since it will be sent as a blank line. Servers restrict the amount of messages that you can send (in a given period of time so you don't spam the message board). Multi-line macros are generally used for talking trash. If you send too many multi-line macros people won't want to play with you anymore and say bad things about your mother.

The real power of macros comes in the ability for the macros to contain some predefined variables. This allows for dynamic macros. These variables will be covered in a section below.

Simple macros are fairly easy to create. You simply need to select your key, who to send it to, and what you want it to say. When you're done you hit the "Save" button. You should be aware that this does NOT save the change to the properties file. Only to the table. So, if you make a mistake you can simply quit the application and restart it.

To save your macro changes to the properties file perminantly you need to use the file menu's "Save" option. This will persist your changes and will be loaded the next time you run the application.

Deleting a macro is very easy. Simply select the macro that you'd like to delete in the table and hit the "Delete" button. Once again, nothing is perminantly saved until you save from the file menu.

To change a macro you need to select the macro you want to change in the table, make your changes and hit "Save".

If you want to create a new macro, hit the "New Macro" button. This will clear out the fields and allow you to create a new macro. Hit "Save" to add the new macro to the table. Use the file menu to persist the change to the properties file.

### Variables

Variables are what make macros interesting. At any point in the text of a macro you can insert a variable that will be replaced when send with real-time information. For example, if you include '%b' in the text of your macro, the name of the planet you are nearest will be reported. As an example:

      If the macro text is:
           I am near %b
      and the closest planet is Earth, then
           I am near Earth
      would be sent to the destination of your message.

There are an awful lot of variables that you can use in your macros and they are listed below with a description of what they do.

    Standard:
    %a   armies carried by sender
    %d   sender damage percentage
    %s   sender shield percentage
    %f   sender fuel percentage
    %w   sender wtemp percentage
    %e   sender etemp percentage
    %t   team id character of target planet
    %T   team id character of sender team
    %c   sender id character
    %n   armies on target planet
    %E   1 if etemped, 0 if not
    %W   1 if wtemped, 0 if not
    %S   sender two character ship type
    %p   id character of target player
    %g   id char of target friendly player
    %h   id char of target enemy player
    %P   id character of player nearest sender
    %G   id char of friendly player nearest sender
    %H   id char of enemy player nearest sender
    %l   three character name of target planet
    %i   sender full player name (16 character max)
    %u   full name of target player (16 character max)
    %z   3 letter team id of target planet
    %b   planet nearest sender
    %o   three letter team name of sender
    %k   number of kills sender has
    %K   number of kills target player has
    %*   if this is encountered, the macro IS NOT PRINTED
    %(SPACE)  this is replaced by a space,
              mainly useful for starting a message

    FULLY CAPITALIZED:
    %L   three character name of target planet
    %I   sender full player name (16 character max)
    %U   full name of target player (16 character max)
    %Z   3 letter team id of target planet
    %B   sender nearest planet
    %O   three letter team name of sender

    Ping stats: (may differ slightly from server '!' ping stats)
    %v   average ping stat round trip time
    %V   ping stat round trip standard deviation
    %y   percent total packet loss as calculated by server formula

    Miscellanous:
    %m   the last message you sent
    %M   the last message you sent in all caps

### Evaluating Tests

Further, tests may be done within the macro system, the syntax for these test is as follows.

    %?   introduces a test
    =    equivalence
    >    greater
    <    less

Expressions are evaluated on a character by character basis until the test is resolved. The text of the test is then replaced in the macro by 1 or 0.

The result of the test is then used with the %{, %! and %} delimiters to actually use the result of the test. %{ looks at the previous character to determin if the test was true or false. If true (1), it will use the text immediatly following the %{ up to the %! character. If false (0) it will use the text after the %! until the %} is encountered. If no %! is found, everything between %{ and %} will be included only if the test is true. Otherwise nothing is printed.

Hopefully this example will make that all clear
Example:

        "1%{included if true%!included if false%}"

        This would print:

        "included if true"

        whereas

        "0%{included if true%!included if false%}"

        would print:

        "included if false"

You can nest conditional statement if you desire. Combining the whole package, a very robust macroing system is quickly generated.