Paradise Macros ------ Last updated 11/11/93 A macro is placed in the .xtrekrc and defined as follows: macro.k.d: value or mac.k.d: value Where 'd' is the destination and 'k' is the key. 'd' is optional (see below). Macros can only be sent out while in macro mode (exception: see SingleMacro). To enter macro mode, press 'X'. Then press the key ('k' above). If the destination is given, the macro is parsed and sent immediately. If not, see below. Destinations: ------------- Normal destinations are 0-9a-z for a player, FRKO for a team, T for your own team, A for all, or G for god. The destination can also be a % code. %I %C Send to self. %U %P Send to player nearest mouse %T %Z Send to team of player nearest mouse %G Send to friendly player nearest your ship %H Send to enemy player nearest your ship If the destination field is not provided, executing the macro will go into a state where it asks for the destination, at which point you should select one of the normal destinations (press F,K,R,O,1-9,etc). When you use a macro, it sends out the value as a message to the destination. There are also several escape sequences that you can use. Escapes: -------- Percent % Escapes: %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 letter of sender %o|%O sender's 3-letter team ID (with case) %c player number of sender %E Boolean: true if etemped %W Boolean: true if wtemped %S sender ship type %i(I) full sender name (capitalized) %t team letter of target planet %r team letter of target player %p number of target player %g number of friendly target player %h number of enemy target player %n armies on target planet %l(L) 3-letter abbreviation of target planet (capitalized) %u(U) full target player name (capitalized) %z(Z) 3-letter team id of target planet (capitalized) %P number of player nearest your ship %G number of nearest friendly player %H number of nearest enemy player %b(B) 3-letter abbreviation of nearest planet (capitalized) %v average ping round trip time %V standard deviation of ping time %y packet loss %m(M) last message (capitalized) % a literal space, allows you to start macros with formatted spaces %% a literal % %? start a test %{ conditional begin %! conditional alternative %} conditional end %* abort the macro and print nothing (useful in conditionals) %2 1 if server is a paradise server, 0 otherwise. %_ includes another macro bound to ; useful if you have "submacros" you reuse at several places. Dollar $ Escapes (new, only in Paradise): Dollar codes are multi-character codes that begin with a $ and are substituted similarly to % codes. They are not meant to replace % codes, they're designed to augment them. start with a $ field 1: relativity (n)earest (thing nearest your ship) (t)arget (thing nearest the mouse) (s)elf (doesn't have fields 2 and 3) (_) ego (has no other fields, substitutes ``Paradise netrek $ codes are orthogonal and make sense.'') field 2: affiliation (a)ny (t)eammate (f)riendly (h)ostile field 3: object (a)ny (u)ser (player) (p)lanet (includes asteroids) (s)tar (n)ebula (b)lack hole (^) non-planet (*) any stellar object field 4: (optional) NYI, case of string (U)ppercase (C)apitalize (L)owercase field 5: property full (n)ame (Hammor, Thought) (i)dentifier (e.g. R5, Ka, Can, Sco) (#) number (0-9a-z for players, %d for planets) (t)eam name (Romulan) (s)hort team id (ROM) (l)etter of team (R) (a)rmies (@) sector (A)rable, 0=not arable, 1=arable but not AGRI, 2=AGRI (M)etal, 0, 1, 2(repair), or 3(sy) (D)ilithium, 0, 1 or 2(fuel) Example: $nhuUn would print the nearest hostile user's name in uppercase. Tests: ------ %?lhs [=<>] rhs lhs and rhs can be specials (the percentages are good for this, as are the booleans) A test will be replaced with either a 1 (true) or 0 (false). Usually, a test is followed by a conditional. Note that no '!=' exists. It is not necessary (see Conditionals). Conditionals: ------------- Conditionals (%{) use the previous position to determine what to print. All conditionals are of the format: %{[text][[%!][test]]%} The %! is a separator. If is true, then the text immediately to the right of the first %{ is printed, otherwise the text after the %! is printed. If only true text needs to be printed, the %! can be ignored. Either side can be empty. For example: 1%{true%!false%} would print 'true'. %E%{ETEMP!%} would print 'ETEMP!' if you're etemped. Here's an example using a test: %?%f<15%{NO GAS!%!%f%% fuel%} which will print 'NO GAS' if your fuel is less than 15%, otherwise it will '% fuel'. Tests and conditionals can be nested. SingleMacro: ------------ SingleMacro allows normal netrek keys to be replaced with a macro. These keys will then override the normal netrek command. The syntax for the .xtrekrc entry is: SingleMacro: For example: SingleMacro: xyzABC The list of keys should all be macros defined elsewhere in your .xtrekrc. Once the SingleMacro line is added, then to send that macro you no longer have to be in macro mode. Just press the macro key (in this case, one of x,y,z,A,B, or C). The macro will be parsed and sent immediately (or, if the destination is missing you will be asked for the destination). SingleMacro keys can also be remapped. If you remap 'd' to be 'A' in your keymap, then when you press 'd', the 'A' macro will be sent. Note that any key you assign to a macro is 'hidden' and cannot be used without using the alt key keymap backdoor (press alt-key and the original interpretation is used instead of the keymap or singlemacro interpretation). Good: mac.G.A: Just an example mac.H.T: ... another mac.J.A: still interested ? singlemacro: GHJ because the keys G,H,J have no vital initial function. Bad: singlemacro: sct because now you can't toggle shields, cloak or fire torps. :-( Examples: --------- Here are some examples from Thought's .xtrekrc: Note: macro definitions must be on single line, no wrapping possible, broken here for readability. mac.a.T: %?%n<0%{TOUCH %2%{$tasUi->%}%L!%!%2%{$tasLi->%}%l@%n%} mac.b.T: bomb %2%{$tasLi->%}%l%?%n>4%{ @ %n%} %2%{%?$tapD>1%{ FUEL%}%?$tapA=2%{ AGRI%}%?$tapM>1%{ REPAIR%}%?$tapM>2%{ SHIPYARD%}%} mac.c: Carrying %?%a>0%{%a arm%?%a=1%{y.%!ies.%}%!no armies.%} #mac.d.T: %E%{%!%W%{%!I'm fine.%}%}%E%{ETEMPED!!! %}%W%{WTEMPED!!! %}Carrying %?%a>0%{%a armies!%!NO armies.%} mac.e.T: Need ESCORT to %l%?%a>0%{, carrying %a arm%?%a=1%{y%!ies!%}%} mac.f.T: %2%{$tasi->%}%l @ %n mac.g.T: going to %l%?%a>0%{, carrying %a arm%?%a=1%{y%!ies!%}%} #mac.h.T: %E%{ETEMPED!!! %}%W%{WTEMPED!!! %}Carrying %?%a>0%{%a armies!%!NO armies.%} mac.r.%H: resistance is futile mac.v: %T%c PING stats: Average: %v ms, Stdv: %V ms, Loss: %y%% mac.D.T: %p++ near %l mac.I.%u: %u: det when you escort! #mac.R.A: I'm a %?%S=SB%{star base!%!twink!%} mac.F.T: %?%S=SB%{Your starbase (%i) is carrying %?%a=0%{NO%!%a%} %?%a=1%{army%!armies%}%!%T%c@%B: I have %?%a=0%{NO%!%a%} %?%a=1%{army%!armies%} on board%} mac.E.T: HELP! %T%c@%B: %?%a=0%{%!%a %?%a=1%{army,%!armies,%}%} %?%d>10%{%d%% dam, %}%?%s<90%{%?%s<15%{NO%!%s%%%} shlds, %}%?%f<15%{NO fuel %!%?%f<90%{%?%S=SB%{%!%f%% fuel %}%}%E%{ETMP!! %}%W%{WTMP!!%!%?%w>90%{%w%% wtmp%}%} ------------------------------------------------------------------------------- Send additions and corrections to paradise-workers@lists.netrek.org Credits: -------- This document was written by Robert Forsman (Hammor) and Bill Dyess (Thought). The original % codes spec and singlemacro idea was stolen from BRM. The % codes code was written by Bill Dyess. The Paradise macro engine was designed and written by Bill Dyess. The Paradise SingleMacro code was written by Bill Dyess The $ codes were invented and written by Robert Forsman. -------- Recovered by Zach, amended by RadoS with some pieces from other version of this text.