|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ATTAC implements REXX scripting standard. Using the Regina REXX interpreter (http://www.lightlink.com/hessling/Regina/index.html ), ATTAC support all standard REXX constructs. New ATTAC Subroutines and Functions ATTAC_ClearBuffer ([<pos>]) Clears the data buffer for the ZOC script. If <pos> is passed, the buffer is only cleared up to that point. All data after that position is still retained. NOTE: This buffer is not the same buffer that the Zoc* functions use. Functions affecting this buffer does not affect the buffer used by the Zoc functions. Example:
/* clear all data up to the 10th character */ ATTAC_Get_Sector_Info (<sector> [, <warp_num> ]) Return information about a sector you have visited. If <warp_num> is not passed, the return value is the number of warps out of this sector. If <warp_num> is passed, return the sector that for the <warp_num> th warp. Example:
/* Get infromation about sector 1 */ ATTAC_Get_ZTM_Sector_Info (<sector> [, <warp_num> ]) Return information about a sector from ZTM data. If <warp_num> is not passed, the return value is the number of warps out of this sector. If <warp_num> is passed, return the sector that for the <warp_num> th warp. Example:
/* Get infromation about sector 1 */ ATTAC_GetBestPairPort(<type>) Return a string of the best pair ports seperated by a space. If either port is on the bust list, it is NOT chosen and then next best pair is chosen.
<type> = "1", return the best equipment-organics pair
Example:
/* getting the best equipment-organic pair and putting into variables
sector1, sector2 */
/* getting the best equipment-fuel pair and putting into variables sector1,
sector2 */
/* getting the best organic-fuel pair and putting into variables sector1,
sector2 */ ATTAC_GetBestEvilPairPort(<type>) Return a string of the best EVIL pair ports seperated by a space. If either port is on the bust list, it is NOT chosen and then next best pair is chosen. <type> = "1", return the best XXB-XXB pair; REQUIRED. Type must be 1. Example:
/* getting the best XXB-XXB pair and putting into variables sector1, sector2
*/ ATTAC_Get_Port_Info (<sector>, <option>) Return information about the port in <sector>. If ATTAC doesn't know about a port in that sector, it returns "Unknown". If there is not Port, it returns "NoPort" The type of information returned is defined by <option>.
<option> = "TYPE", return the type of port 0-9
Example:
/* Get information about the port in sector 1 */
No_Port:
Quit_Script:
ATTAC_GetTotalSectors () Returns the number of sectors in the game, as defined by the user during the creation of the game. Example: totalSectors = ATTAC_GetTotalSectors() ATTAC_GetStardockSector () Returns the sector the stardock is in, as found when playing. If the stardock sector is unknown, a -1 is returned. Example: totalSectors = ATTAC_GetStardockSector() ATTAC_GetBuffer () Returns the script buffer. NOTE: This buffer is not the same buffer that the Zoc* functions use. Functions affecting this buffer does not affect the buffer used by the Zoc functions. Example: buffer = ATTAC_GetBuffer() ATTAC_IsSectorBusted(<sector>) Tells you if the you were busted in that <sector> . Return Values are:
-1 = If you enter an invalid sector or unknown Example: tmp1 = ATTAC_IsSectorBusted("294")if tmp1 = 1 then do call ATTAC_Message ("You were busted in this sector") end else do call ATTAC_Message("You were NOT busted in this sector") end ATTAC_IsSectorAvoided(<sector>) Tells you if the you have avoided that <sector> . Return Values are:
-1 = If you enter an invalid sector or unknown Example: tmp1 = ATTAC_IsSectorBusted("294")if tmp1 = 1 then do call ATTAC_Message ("This sector is avoided") end else do call ATTAC_Message("This sector is NOT avoided") end ATTAC_HasSectorFig(<Sector>) Tells you if a <sector> has a fighter and if the fighter is yours, an ally or an enemy fighter. Return Values are:
-1 = There are no fighters in the sector or you entered and invalid sector. Example:
tmp1 = ATTAC_HasSectorFig() ATTAC_Message (<message>,[<color>],[<intro>]) Adds a message to the ATTAC Message Center.
<message> = This is the actual message that gets added. Example:
CALL ATTAC_Message("This is a test") CALL ATTAC_Message("This is a test","YELLOW")
CALL ATTAC_Message("This is a test","GREEN","My Message") ATTAC_SectorFigAmount(<sector>) Tells you how many fighters are in a <sector> Return Values are:
-1 = There are no fighters in the sector or you entered and invalid sector. Example:
tmp1 = ATTAC_SectorFigAmount("294") ATTAC_SectorFigOwner(<sector>) Tells you the name of the owner of the fighters in the <sector> . Return Values are:
"Unknown" = ATTAC doesnt know who the owner of the fighters are. Example:
tmp1 = ATTAC_SectorFigOwner("294") ATTAC_SectorFigType(<sector>) Tells you the type of fighters in the <sector> . Return Values are:
-1 = If you enter an invalid sector or unknown Example: tmp1 = ATTAC_SectorFigOwner("294")if tmp1 = 1 then do call ATTAC_Message ("Toll Fighters") end ATTAC_StartBuffer () Start placing incoming data into the script buffer. NOTE: This buffer is not the same buffer that the Zoc* functions use. Functions affecting this buffer does not affect the buffer used by the Zoc functions. Example: CALL ATTAC_StartBuffer() ATTAC_StopBuffer () Stop placing incoming data into the script buffer. NOTE: This buffer is not the same buffer that the Zoc* functions use. Functions affecting this buffer does not affect the buffer used by the Zoc functions. Example: CALL ATTAC_StartBuffer() ATTAC_UpdateCounter ([<inc_val>]) Update the script counter by <inc_val> or by 1 if <inc_val> is not passed. Example:
/* Count from 2 - 20 in the script counter */ Supported ZOC Subroutines and Functions ZocAsk (<title> [, <default>]) Get the user a question in a dialog box. If <default> is provided, the input box will be preset to that value. Example: Sector = ZocAsk ("Which sector would you like to warp to?", "1") ZocAskP (<title> [, <default>]) Same as ZocAsk except the input box is displayed using the password symbol (*) Example: Password = ZocAskP ("Enter your password: ") ZocBeep (<n>) Beep <n> times. Example: CALL ZocBeep (3) ZocClearBuffer () Clears ATTAC parsing buffer Example: CALL ZocClearBuffer () ZocCls () Clear the game window. Example: CALL ZocCls () dosfname ( <filename>) Returns the filename with an absolute path using the ATTAC directory that attac.exe is located in. Example: CALL ATTAC_Message(dosfname ("script.ini"))
This returns "C:\Program Files\ATTAC\script.ini" assuming that attac.exe
is located in "C
:\Program Files\ATTAC" dosisdir (<directory>) Returns a 0 or a 1 depending on if the <directory> exists or not
0 = The directory does not exist Example: CALL ATTAC_Message(dosisdir ("c:\test")) This returns 0 if the directory does not exist and 1 if it does ZocDelay ( [<sec>] ) Pause the script for <sec> seconds. If <sec> is not provided, pause for 0.2 seconds. Example: CALL ZocDelay (5) ZocGetLine () Wait for the next non empty line of text from the game. The received text can be accessed from ZocLastLine. ZocGetLine waits for line until the timeout is reach, at which time it returns with "640" NOTE: Due to different processing, ATTAC does not miss any incoming data. Thus ZocSynctime is not implemented. Example:
Timeout = ZocWait ("[Pause]") ZocGetFileName () Opens a Common Dialog box and prompts the user to select a filename. You can either select a file or click CANCEL.. If user clicks CANCEL, the string ##CANCEL## is returned. Example:
tmp1 = ZocGetFileName() ZocLastLine () Returns the line of text when the last ZocGetLine / ZocWait / ZocWaitMux returned. Example:
Timeout = ZocWait ("]:[") ZocLogname (<filename>) Change the name of the log file to <filename>. Only takes effect after you call ZocLogging(1). Example:
/* Create a logfile with the name attac_zoc.log */
ZocLogging (<on_off>) Turns the logging on (<on_off> = 1) or off (<on_off> = 0). You can set the name of the log file with ZocLogname. Example:
/* Create a logfile with the name attac_zoc.log */
ZocLockKeyboard (<lock>) Lock (<lock> = 1) / Unlock (<lock> = 0) the keyboard to prevent the user to send keys while your script is running. The keyboard is automatically unlocked at the termination of the script. Example:
/* Prevent the user from typing for 5 seconds */
Lower (<string>) Changes the <string> to lowercase Example: /* Prevent the user from typing for 5 seconds */tmp1 = Lower ("THIS Word") Call ATTAC_Message(tmp1) This should printout "this word" (without quotes) ZocKeyboard(<command>) This function allows a REXX script to lock/unlock the keyboard. ZocMsgBox (<text> [, <mode>]) Display a message box containing <text>. The three different types of message boxes are:
<mode> = 0 Simple dialog box with an OK button
If <mode> is not provided, a simple dialog box with an OK button is used. The return values are "##OK##", "##YES##", "##NO##". Example:
result = ZocMsgBox ("Out of money", 2) ZocNotify (<text>) Display a temporary window containing <text>. This window is displayed for 3 seconds. Example:
Sector = Sector + 1 ZocOs () Returns the OS name and version. Currently returns only "WINNT 4.00". Example: Os = ZocOs () ZocRequest (<title>,<opt1> [, <opt2 > [, <opt3> … [, <optn>]]]) Display a list of options for the user to pick from. The number of options is not limited. The return value is the text of the option chosen. Example:
Answer = ZocRequest ("Which planet would you like to land on?", "Planet
1", "Planet 2", "Planet 3", "Planet 4")
IF Answer = "Planet 2" THEN DO /* Etc.. */ ZocRequestList (<title>,<opt1> [, < opt2 > [, <opt3> … [, <optn>]]]) Display a requester window with a list of options and return the index of the selected option (or -1 for Cancel). If only one option is passed to the function, it is considered as a list of choices separated by vertical bars. Example:
Answer = ZocRequest ("Which planet would you like to land on?", "Planet
1", "Planet 2", "Planet 3", "Planet 4")
IF Answer = 2 THEN DO /* Etc.. */ ZocRespond (<prompt> [, <response>]) If <response> is provided and doeZocClearBuffer s not equals "", then send <response> whenever <prompt > is encountered, but ONLY while ZocGetLine, ZocWait, and ZocWaitMux are processing. If <response> is not provided or equals "", then this response is canceled. NOTE: This command uses more CPU time than normal. Therefore, it is recommended that you cancel a response as soon as you don't need it anymore. Example:
/* continue past all "[Pause]" until "Command" is reached */
ZocScreen (<x>, <y>, <length>) Returns <length> characters on game screen starting at coordinates <x>,<y>. <x> and <y> start at 0,0 in the upper left hand corner. Example: Data = ZocScreen(0, 0, 10) ZocSend (<text>) Send <text> to the game. The text in <text> is first expanded inserting the proper control characters in place of the control codes. See below for a list of the command codes and their meanings. Example: /* Send the username and a return key */ CALL ZocSend (username || "^M") ZocSendRaw (<text>) Same as ZocSend except it doesn't expand <text>. Example:
/* Send the username and the string "^M" */
ZocSetOption (<text>) This Command is accepted but not interpreted. ZocTimeout (<sec>) Set the timeout used by ZocGetLine, ZocWait and ZocWaitMux to <sec > seconds. Example:
/* Wait for 5 seconds for the text before returning */
ZocWait (<text>) Wait for <text> in the input stream before returning. If ZocWait times out, it will return 640. Example:
Timeout = ZocWait (text) ZocWaitMux (<text1> [, <text2> [, < text3 > … [, <textn>]]] Same as ZocWait except wait for multiple inputs. As soon as one of them is found, it returns the index of the <text?> found. (1 for < text1>, 2 for <text2>, etc.) If ZocWaitMux times out, it will return 640. Example:
Result = ZocWaitMux ("offer", "not interested")
ZocWrite (<text>) Write <text> to the screen at the current cursor position. < text> is expanded using control codes. This is similar to the REXX command SAY, but it does not place an enter at the end of the line. Example: CALL ZocWrite ("Starting the script! ^M") ZocWriteln (<text>) Similar to ZocWrite, except it places an enter at the end of the line. Example:
CALL ZocWriteln ("Starting the script!") ZocExec <command>, [<viewmode>] Execute a program directly (ie. without passing it through the shell handler, thus avoiding the black shell window). This does only work for .com and .exe files (not for .cmd and internal commands like DEL, REN etc.). optional viewmode parameter controls how the application window
is shown: ZocExec also returns the exit code of the application. CALL ZocExec ("notepad.exe") This function returns information about the current ZOC session. Items: CONNECTEDTO CURSOR-X CURSOR-Y DOWNLOADDIR ONLINE OSYS VERSION WORKDIR ZocGetGlobalOption(<item>) - (this is the same as ZocGetOption) This function returns information about the current options. Items: VTStripSeq CaptDefaultName ScriptPath CapturePath ScriptPath WindowTitle Example: ZocReceiveBuf(<buffer size>) CALL ZocSend "i" ZocString(<subcommand>, <inputstring>, <p1>, [<p2>]) This is a function to manipulate a string and return a modified copy. The subcommand and the parameters <p1> and <p2> control the modification. Subcommands: PARTCOUNT REPLACE REMOVECHARS ZocWaitForSeq 1|0 Normally ZocWait commands do not see emulation control codes in
the data stream. If you need to wait for an emulation control you can
use this command. This flag also turns on/off filtering of emulation
controls for ZocReceiveBuf(). Example: /* rexx example */ ZocSyncTime This Command is NOT implemented. It is just interpreted for compatability with with other scripts. ATTAC has no need for this command has it syncronizes it's threads.
Unsupported ZOC Subroutines and Functions The following ZOC subroutines and functions are not been implemented either due to no relevance or new different ways of implementing the underling algorithms.
Differences between ZOC and ATTAC ATTAC and ZOC have different internal structure that cause slight changes in the way scripts are executed. The main differences are as follows: ATTAC does not miss any data due to different threads This has been the cause of many problems. Lost data is never a good thing, and ATTAC avoids this problem by using a more advanced internal algorithm. ATTAC is more serialized with respect to ZocRespond and ZocGetLine/ZocWait/ZocWaitMux due to better synchronization handling The following code fragment use to work but no longer does due to the better handling of data.
CALL ZocRespond ("[Pause]", "^M") This fragment would wait for "[Pause]", send and enter, and continue. However, since the text sent to ZocWait is missing the trailing "]", it breaks out of ZocWait before ZocRespond sees the final "]", and therefore the enter is never sent, since ZocRespond only works while ZocGetLine, ZocWait or ZocWaitMux are waiting for data. ATTAC does not place limits on the number of parameters passed to ZocRequest or limits on the number of ZocRespond requests . This does not effect the execution of scripts, but does allow more flexibility. ATTAC is stricter in calling ZOC commands. ATTAC does not support the calling method such as the following: ZocDelay 2 Instead, use the following method CALL ZocDelay(2) OR ZocDelay(2) Control Codes
ATTAC REXX Scripting reference |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|