home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / twterm30.zip / SCRIPT.DOC < prev    next >
Text File  |  1994-07-07  |  20KB  |  412 lines

  1. Instructions on using TWTERM's script language for creating macros.
  2. ====================================================================
  3.  
  4.   OK before I show you whats available in this script language, lets
  5. take a little lesson on how to write a macro.
  6.  
  7.   A macro can send keypresses to the modem. By using a macro, you don't
  8. have to punch the keys in. Thus a macro can do things in TW that you
  9. normally doing by pushing keys on the keyboard.
  10.  
  11.   Heres an example... You want to create a capture file that lists all
  12. your assets in a game. The first thing you need to do is to display
  13. your assets to the screen so they can be saved in the capture file.
  14.  
  15.   Your assets consist of.. fighters, planets, ships, mines. So what are the
  16. TW commands for displaying those? Hitting "T" then "L" lists your Corporate
  17. planets, "C" then "Y" lists your personal planets. Hitting "G" displays
  18. your fighters, etc...
  19.  
  20.   As you can see, you'll be having to press a lot of keystrokes to display
  21. all your assets. Instead you could push just one key and let a macro run
  22. it all for you. To code the above example, you would have the macro send
  23. the keystrokes for you. To do this you use the SEND command.
  24.  
  25.   For example, let's display your Personal planets. If you're at TW's main
  26. prompt then you'll need to enter the computer by pressing "C". Then list
  27. the planets by sending "Y".  So you need to send "C" then "Y". Would help
  28. to send "Q" also which will return you to TW's main prompt.
  29.  
  30.   Now that you have determined to send "C", "Y", "Q", you need to know when
  31. to send them. Thus you must tell TWTERM the next prompt to look for so it
  32. can send the next keystroke. In our example, you want to start the macro
  33. from TW's Main prompt then go to the computer prompt by sending "C". So after
  34. sending "C" you must look for the computer prompt. TWTERM by default has the
  35. Computer prompt stored in a variable (that way you dont have to remember what
  36. it is). The prompt for this is stored in variable %9 (more on variables later)
  37.  
  38.   So you want to send "C" then look for Computer prompt. to code this
  39. you would type (commands must be enclosed within {} brackets)...
  40.  
  41.                           {send C}{%9}
  42.  
  43.   After sending "C" and reaching the Computer prompt, your macro will check
  44. to see if there is another keystroke. If so it continues.. if not, control
  45. is returned to you.
  46.  
  47.   that's basically all there is to macros. But to finish our example.. here is
  48. the rest of the code needed to display your Personal planets...
  49.  
  50.                   {send C}{%9}{send Y}{%9}{send Q}{%0}
  51.  
  52.   %0 is the variable that contains the Main prompt. So you send "C", look
  53. for Computer prompt. Send Y, look for Computer prompt. Send Q and look
  54. for when you return to the Main TW prompt.
  55.  
  56.   Easy, huh?  Now you can finish the rest of the macro yourself. Have Fun
  57.  
  58. ====================================================================
  59.                    !!!!!!!!  ABORT MACRO  !!!!!!!!
  60.  
  61. There are going to be times you miscode a macro. Or perhaps line noise
  62. came in and interrupted the macro. Maybe you started the macro from the
  63. wrong place in your game. In any case, if you find yourself stuck in a
  64. macro, use the <ESC> key to get out of it.
  65.  
  66. How will you know when you are stuck? The screen will sit there and
  67. not end where it should. The keyboard won't respond to your keypresses.
  68. Hit <ESC> anytime you're stuck or just want to end a macro.
  69.  
  70. NOTE: Sometimes hitting < ESC > won't work the first time. Just keep hitting
  71. <ESC> until you exit.
  72.  
  73. ===================================================================
  74.                              variables
  75.  
  76. There are 33 variables numbered %0 thru %34 that are available for use.
  77. Use these variables for storing of data. Useful when using loops and to
  78. save time typing.
  79.  
  80. Some of the variables are used for special purposes. However you can
  81. still access them and even overwrite them. Here is the complete list:
  82.  
  83. %1 - %8     Available for your use when writing your own macros.
  84.      %0     Contains TW's Main prompt. Use this variable to find out
  85.                when you have returned to TW's main prompt
  86.      %9     Contains TW's Computer prompt. Use this to find out when
  87.                you have reached/returned to the Computer prompt
  88. %10-%13     Used by the Built-In macros when being executed. You can use
  89.                these for your macros, but when a Built-In macro is run
  90.                it will erase anything you have stored here.
  91.     %14     Password for the Underground stored here. When you run TWTERM's
  92.               LOCK/UNLOCK UNDERGROUND macro, TWTERM saves the password in
  93.               this variable. Should you wish to return to the Underground,
  94.               you can do so easily with your own script macro: {SEND %14}{}
  95.               No need to run the LOCK/UNLOCK macro again (saves credits)
  96.     %15     Current path is stored here
  97.     %16     Contains location of Stardock if found in .DAT file. If found
  98.               use this in a macro to take you to Stardock.
  99.     %17     Used for storing offer when price haggling via the HAGGLE command
  100.     %18     Contains the current sector you are in. Can copy the contents
  101.               of this variable to another variable. Example: {%1 = %18}
  102.               Now whenever you want to go back to the sector you started in,
  103.               you just send variable 1. Example {SEND %1;}{%0}
  104.     %19     Contains the current sectors Class Type if a port exists.
  105.               If not, contains Class Type of last port visited.
  106.     %20     Contains ships password. Use this variable in a macro when
  107.               you need to send a password for one of your ships.
  108.               Example:  {SEND %20}{}
  109.     %21     Used by built-in macros to determine whether your ship is
  110.               equipped with a Trans-Warp Drive. The colonize macro uses
  111.               This variable.
  112.     %22     Used by the planet macros to determine/handle the prompts
  113.               you will encounter when trying to land on a planet.
  114.     %23     When writing macros for shooting Disruptors, the prompt
  115.               that asks if you want to fire one changes between
  116.               the different versions of TW. Thus if you play in these
  117.               different version, you may want to use this variable so
  118.               your macro is compatible with all versions of TW 2.0.
  119.               Example:  {send w}{%23}
  120.     %24     Port prompt (first prompt you get after "P"ort). Useful when
  121.               writing macros for trading, since this prompt is different
  122.               between the MajorBBS version of TW and the dorr version.
  123.               Use this variable and your macro will work in both versions.
  124.               Example:  {send p}{%24}
  125.     %25     The prompt stored here is the one you get when leaving/taking
  126.               colonists from your planet. The one that asks, which colonists
  127.               to take/leave. Useful when writing macros for colonizing,
  128.               since the prompt stored here changes between the door TW 2.0
  129.               and the MajorBBS version. Use this variable and your macro
  130.               will work in both versions.
  131.               Example:  {send s}{net?}{send n}{[L]}{send L}{%25}
  132.     %26     The prompt stored here is the one you get when stealing a product
  133.               from a port. The prompt is the one that asks what type of
  134.               product you wish to steal. Useful when writing macros for
  135.               stealing since the prompt stored here changes between TW 2.0
  136.               and the MajorBBS version of 2.0. Use this variable and your
  137.               macro will work in both versions.
  138.               Example:  {send s}{%26}{send 3}{]}{send %1;}{%0}
  139.     %27     This prompt appears when taking a product off of your planet.
  140.               After you get the "Take or Leave" prompt.. you specify T or
  141.               L.. then you get this prompt. Use this variable so you macro
  142.               will be compatible with all version of TW 2.0
  143.               Example:  {send t}{net?}{send n}{[T]}{send t}{%27}
  144.     %28     This is the prompt that appears when handling or displaying
  145.               mines. It is the one that asks you to select Armid or Limpet
  146.               mine. It changes between the different versions of TW 2.0. Use
  147.               variable to keep compatibility.
  148.               Example:  {send K}{%28}{send 1}{%0}
  149.     %29     Not in use yet
  150.  %30-%33    Trade Percentages used by TWTERM. Not wise to mess with these
  151.               But if you must use a macro for changing these values (don't
  152.               really need to because you can do it from the F8 menu in
  153.               TWTERM)  then here isa breif rundown..
  154.               %30 = How much HIGHER your initial offer is compared to ports
  155.                     offer.
  156.               %31 = How much LOWER your initial offer is compared to ports
  157.                     offer.
  158.               %32 = How much HIGHER/LOWER to increment your counter offers
  159.                     in case the port didn't take your initial offer.
  160.                     offer.
  161.               %33 = This is the percentage amount a port needs on hand to
  162.                     to earn a "*" in the Best Ports Listing.
  163.  
  164. When TWTERM encounters some of these variables in your macro, it will check
  165. to see if the macro contains anything (applies only to variables %1-%8).
  166. If blank, you will be prompted for input, if the variable contains
  167. something, it will use that instead of prompting for input. (See the SET
  168. command on how to manipulate variables).
  169.  
  170.  
  171. Here is a list of prompts that have changed in the Door version
  172. of TW 2.0 and the MBBS version of TW 2.0. If you find your macro works in one
  173. version but not the other, try using a variable instead in your macro. Look
  174. for the following prompt strings and change it to the apprpriate variable.
  175.  
  176. Variable      Prompt String          Where you may find
  177.  To Use      Door       MBBS         this prompt string
  178.  
  179.   %23       one ?       one?        When Launching Disruptors
  180.   %24       T] ?        T]?         When Porting
  181.   %25       tion?       duct?       When Leaving/Taking colonists
  182.   %26       uit) ?      uit)?       When Stealing product from port
  183.   %27       nt ?        nt?         When Taking product off of planet
  184.   %28       impet?      t ? :       When choosing mines
  185.  
  186. If you're not playing in the different formats of TW then you don't need
  187. to worry about these prompts.
  188.  
  189. ==========================================================================
  190.                              Operators
  191.      Operators perform mathmatical or logical operations on variables.
  192.  
  193. =   Use to put a numeric value or text string into a variable.
  194.     Syntax:  {Variable = Number/TextString}
  195.  
  196. *   Multiplies a variable by a number you specify
  197.     Syntax:  {Variable * Number}
  198.  
  199. /   Divides a variable by a number you specify
  200.     Syntax:  {Variable / Number}
  201.  
  202. +   Adds to a variable a number you specify
  203.     Syntax:  {Variable + Number}
  204.  
  205. -   Subtracts from a variable a number you specify
  206.     Syntax:  {Variable - Number}
  207.  
  208.     Examples: {%10 = 889}               Puts "889" into variable 10
  209.               {%4 = Hello Commander}    Puts "Hello Commander" into 4
  210.               {%3 * 2}                  Multiplies variable 3 by two, then
  211.                                         stores the answer back in var 3
  212.  
  213. ==========================================================================
  214.                               Labels
  215.  
  216. Labels are used to branch back to a previous part of your macro. These
  217. are extremely helpful when coding a loop for your macro.
  218.  
  219. The label can be any string of text you want, as long as you add a ":"
  220. to the beginning of your labels name. The following are all valid labels:
  221.  
  222. {:again}  or  {:Do Again}  or {:A}
  223.  
  224. As you can see, your label must be enclosed within a set of "{}" brackets.
  225. You can use upper or lowercase characters. You can have as many labels as
  226. you want in your macro as long as each label has it's own unique name.
  227.  
  228. ==========================================================================
  229.                           AVAILABLE commands
  230.  
  231. 1)  All commands must be enclosed within the {} characters.
  232.         EX:   {Command}
  233.  
  234. 2)  Commands must be entered with no spaces between the brackets.
  235.         EX:   {Command}{Command}    This is valid
  236.               {Command} {Command}   This is not valid
  237.  
  238. 3)  Commands can be entered in Upper or Lower case.
  239.  
  240. ------------------------------------------------------------------------
  241. BEEP     Makes a Beep sound.
  242.  
  243.   Syntax:   {BEEP}
  244.  
  245. ------------------------------------------------------------------------
  246. CHKBUST     If you have coded a macro that does a rob or steal loop, then
  247.             you will want to use this command to check if you were busted.
  248.             If so the macro will end, if not it will continue with the loop.
  249.  
  250.   Syntax:   {CHKBUST}
  251.  
  252.   Example:   {:loop}
  253.              {your rob/steal code goes here}
  254.              {chkbust}
  255.              {goto loop}
  256.  
  257. ------------------------------------------------------------------------
  258. GOTO     Branches to another part of your macro. Excellent for creating
  259.          loops in your macros
  260.  
  261.   Syntax:   {GOTO LabelName}
  262.  
  263. Parameters:   LabelName
  264.  
  265.                   where LabelName is the name of the label you want the
  266.                   macro to branch to. The macro then executes all of the
  267.                   commands following that label.
  268.  
  269. SPECIAL NOTE:  LabelName MUST NOT be preceded with a ":". Only the name
  270. of the label. Also, LabelName is not case sensitive. Captalization doesn't
  271. matter as long as the name is spelled correctly.
  272.  
  273.   Example:   {:loop}{beep}{goto loop}
  274.              {:again}{set}{goto AGAIN}
  275.              {send d}{%0}{:HERE}{SEND D}{%0}{GOTO here}
  276.  
  277.              the above are all valid
  278.  
  279. ------------------------------------------------------------------------
  280. HAGGLE     Calculates best price to offer when trading, then stores
  281.            the amount in variable %17. Also turns on "Haggle Mode".
  282.          
  283.   Syntax:   {HAGGLE -}{EndWhere} or {HAGGLE +}{EndWhere}
  284.  
  285.   Parameters:   - or +
  286.  
  287.                 "-" tells the macro you want to buy. Thus your offer will be
  288.                     calculated less then what the port is offering.
  289.  
  290.                 "+" tells the macro you are selling. Thus your offer will be
  291.                     calculated more then what the port is willing to pay.
  292.                 
  293.                 EndWhere
  294.  
  295.                   This tells TW where to end this command. Enter here
  296.                   the last few letters of the next prompt. Usually the next
  297.                   prompt will be TW's main prompt (if you are done with that
  298.                   port), or another trade prompt askinf if you want to sell
  299.                   or buy something else.
  300.    
  301.     Example:   {haggle +}{%0}
  302.  
  303.                The above macro works at a CLASS 8 port and provided you have
  304.                only 1 type of product on your ship. After you port and
  305.                specify you want to trade, the port will make you an offer.
  306.                Run the above macro. It will findout what that offer is,
  307.                calculate your offer, then send it back to TW. The macro will
  308.                haggle until your offer is accepted, then return you to the
  309.                main prompt (%0).
  310.  
  311. ------------------------------------------------------------------------
  312. SEND     Sends the TW command you want to execute to the modem
  313.          
  314.   Syntax:   {SEND CharacterToSend}{EndWhere}
  315.  
  316.   Parameters:   CharacterToSend
  317.  
  318.                   is the TW command to execute, or user variable you want
  319.                   executed. If you want a carriage return added put a ";"
  320.                   on the end.
  321.  
  322.                 EndWhere
  323.  
  324.                   This tells TW where to end this command. Enter here
  325.                   the last few letters of the next expected prompt.
  326.  
  327.    Example:   {send 4;}{%0}
  328.  
  329.               Unlike other commands in TW, when you move sectors you need
  330.               to press <ENTER> to execute the command. By adding ";" to the
  331.               end of string to execute, you send an <ENTER> key with it.
  332.  
  333.               The above example sends to TW a "4" and an "ENTER" key. Thus
  334.               telling it to move to sector 4. The {%0} says to return
  335.               control back to TWTERM when the Main Menu prompt is
  336.               encountered.
  337.   
  338.    Example:   {SEND %1}{%0}
  339.  
  340.               Here you are sending whatever you have stored in variable one
  341.               If you have stored nothing there, you will be prompted to
  342.               enter a string of text for execution and storage. Most useful
  343.               when wanting to run the same macro over and over, thus you
  344.               only have to enter the data once.
  345.  
  346.   Examples:     {Send c}{p)?}{send n}{p)?}{SEND Q}{p) ?}
  347.               
  348.               This macro is started from the main prompt. The first set
  349.               of brackets tells TWTERM to send the "C" command (enter the
  350.               computer), the second set of brackets tell it to wait until
  351.               it gets to the computers prompt "p)?". This prompt to search
  352.               for is also stored in variable %9. So this command is just as
  353.               valid: {Send c}{%9}
  354.              
  355.               Once it gets to the computer prompt it starts the next
  356.               command (set of brackets). The next one says to send "N"
  357.               which will toggle the color, and wait again until you get
  358.               back to the computer prompt.
  359.  
  360.               The third SEND command sends "Q" telling TW to exit the
  361.               computer and return to the main menu. At the end of this
  362.               command you see "p) ?" (the last 4 letters of TW's main menu
  363.               prompt), which tells it to wait until it gets back to TW's
  364.               main menu prompt.
  365.  
  366.               With this macro, you can now turn on/off the color in TW
  367.               while at the main prompt instead of just at the computer
  368.               prompt.
  369.  
  370.               This macro works with TW 1.03 versions, not 2.0. Just an
  371.               example. You'll need to modify it for 2.0 if you want to
  372.               use it.
  373.  
  374. ------------------------------------------------------------------------
  375. SET    Clears User variables
  376.  
  377.   Syntax:   {SET} or {SET variable}
  378.  
  379.   Parameters:  variable
  380.  
  381.                    is one of the 23 valid variables from %0 thru %22
  382.  
  383. Using SET without a variable, initilizes variables %0 and %9 to their
  384. original default values. %1-%8 and %10-%13 are st to null. The other
  385. variables are left unchanged.
  386.  
  387. Specifing a variable clears only that variable. All variables are valid
  388. here.
  389.  
  390.   Examples:   {set %8}       clears variable 8
  391.               {set}          clears all variables between 0-13 and sets
  392.                              %0 and %9 to their original default values
  393.  
  394. --------------------------------------------------------------------------
  395. ERROR messages
  396. The following are some of the macro error messages you may encounter.
  397.  
  398. * Incorrect Command
  399.    This occurs when you have issued a command that TWTERM doesn't recognize.
  400.    Perhaps you have spelled it incorrectly, or used the wrong syntax.
  401.  
  402. * Wrong Syntax For Label
  403.    You're label does not have a ":" at the beginning of it, or perhaps
  404.    your forgot to enclose it within the "{}" brackets.
  405.  
  406. * Label Not Found
  407.    You issued a GOTO command and the label you specified cannot be found
  408.    in the macro. Make sure your GOTO statement doesn't have a ":" at the
  409.    beginning of the label name. Also check to see if the label name is
  410.    spelled the same as the one you are using in your GOTO.
  411.  
  412.