TWX Proxy Script Reference v2.04



Welcome to the TWX Proxy script reference. This document is designed specially for programmers, scripters, or just people that want to learn TWX Proxy a little better. Unfortunately there is currently no specification detailing language syntax or the internals of how things actually work, although easily the best way of learning this is to just read over the open source pack1 scripts or the unencrypted portions of the pack2 scripts and see how they work.


Contents



Script Commands

Many of these commands exist only for internal use or backwards compatibility.

   add
   addMenu
   and
   branch
   clearAllAvoids
   clearAvoid
   clientMessage
   closeMenu
   connect
   cutText
   delete
   disconnect
   divide
   echo
   fileExists
   getAllCourses
   getCharCode
   getConsoleInput
   getCourse
   getDate
   getDistance
   getFileList
   getInput
   getLength
   getMenuValue
   getNearestWarps
   getOutText
   getRnd
   getScriptVersion
   getSector
   getSectorParameter
   getText
   getTime
   getTimer
   getWord
   getWordPos
   gosub
   goto
   halt
   isEqual
   isGreater
   isGreaterEqual
   isLesser
   isLesserEqual
   isNotEqual
   isNumber
   killAllTriggers
   killTrigger
   killWindow
   listActiveScripts
   listAvoids
   listSectorParameters
   load
   loadVar
   logging
   lowerCase
   mergeText
   multiply
   openMenu
   or
   pause
   processIn
   processOut
   read
   readToArray
   rename
   replaceText
   reqRecording
   return
   round
   saveVar
   send
   setArray
   setAvoid
   setDelayTrigger
   setEventTrigger
   setMenuHelp
   setMenuOptions
   setMenuValue
   setPrecision
   setProgVar
   setSectorParameter
   setTextLineTrigger
   setTextOutTrigger
   setTextTrigger
   setVar
   setWindowContents
   sound
   stop
   stripText
   subtract
   systemScript
   upperCase
   waitFor
   window
   write
   xor

Script Macros

Do not confuse script macros with commands. Although they are used in the same way, they differ on a technical level. These macros basically act as a substitute for groups of commands. They are a quick and easy way to write powerful scripts.

   IF
   INCLUDE
   WAITON
   WHILE

System Values

The system values can be accessed from anywhere in a script simply by using their name. Their values will change depending upon the environment.

   ALPHACENTAURI
   ANSI_0
   ANSI_1
   ANSI_10
   ANSI_11
   ANSI_12
   ANSI_13
   ANSI_14
   ANSI_15
   ANSI_2
   ANSI_3
   ANSI_4
   ANSI_5
   ANSI_6
   ANSI_7
   ANSI_8
   ANSI_9
   CONNECTED
   CURRENTANSILINE
   CURRENTLINE
   CURRENTSECTOR
   DATE
   FALSE
   GAME
   GAMENAME
   LICENSENAME
   LOGINNAME
   PASSWORD
   PORT.BUILDTIME
   PORT.BUYEQUIP[sector]
   PORT.BUYFUEL[sector]
   PORT.BUYORG[sector]
   PORT.CLASS[sector]
   PORT.EQUIP[sector]
   PORT.EXISTS[sector]
   PORT.FUEL[sector]
   PORT.NAME[sector]
   PORT.ORG[sector]
   PORT.PERCENTEQUIP[sector]
   PORT.PERCENTFUEL[sector]
   PORT.PERCENTORG[sector]
   PORT.UPDATED
   RAWPACKET
   RYLOS
   SECTOR.ANOMOLY[sector]
   SECTOR.BACKDOORCOUNT[sector]
   SECTOR.BACKDOORS[sector][index]
   SECTOR.BEACON
   SECTOR.CONSTELLATION
   SECTOR.DENSITY[sector]
   SECTOR.EXPLORED[sector]
   SECTOR.FIGS.OWNER[sector]
   SECTOR.FIGS.TYPE
   SECTOR.FIGS.QUANTITY[sector]
   SECTOR.LIMPETS.OWNER[sector]
   SECTOR.LIMPETS.QUANTITY[sector]
   SECTOR.MINES.OWNER[sector]
   SECTOR.MINES.QUANTITY[sector]
   SECTOR.NAVHAZ[sector]
   SECTOR.PLANETCOUNT[sector]
   SECTOR.PLANETS[sector][index]
   SECTOR.SHIPCOUNT[sector]
   SECTOR.SHIPS[sector][index]
   SECTOR.TRADERCOUNT[sector]
   SECTOR.TRADERS[sector][index]
   SECTOR.UPDATED[sector]
   SECTOR.WARPCOUNT[sector]
   SECTOR.WARPINCOUNT[sector]
   SECTOR.WARPSIN[sector][index]
   SECTOR.WARPS[sector][index]
   SECTORS
   STARDOCK
   TIME
   TRUE

Terminal Menu References

The terminal menu references are the names of the built-in TWX Terminal Menus. These menus can be accessed using the menu scripting commands (addMenu, setMenuValue, getMenuValue, etc)

   TWX_ACCEPTEXTERNAL
   TWX_BUBBLESIZE
   TWX_BURST
   TWX_CACHE
   TWX_CONNECT
   TWX_DATA
   TWX_DATABASE
   TWX_DATABASE_CREATE
   TWX_DATABASE_DELETE
   TWX_DATABASE_EDIT
   TWX_DATABASE_SELECT
   TWX_DATABASE_VIEW
   TWX_DUMPSCRIPTVARS
   TWX_EDITBURST
   TWX_EXIT
   TWX_HOLOSCAN
   TWX_KILL
   TWX_LISTACTIVE
   TWX_LISTDIRECTORY
   TWX_LISTENPORT
   TWX_LISTPORTS
   TWX_LISTUPGRADEDPORTS
   TWX_LOADLASTSCRIPT
   TWX_LOADSCRIPT
   TWX_LOCALECHO
   TWX_LOG
   TWX_LOGANSI
   TWX_MAIN
   TWX_PLOTCOURSE
   TWX_PORT
   TWX_RECONNECT
   TWX_REPEATBURST
   TWX_SCRIPT
   TWX_SCRIPTKEY
   TWX_SCRIPTTEXT
   TWX_SETUP
   TWX_SHOWANOM
   TWX_SHOWBACKDOORS
   TWX_SHOWBUBBLE
   TWX_SHOWBUBBLES
   TWX_SHOWCLIENTS
   TWX_SHOWDENSITY
   TWX_SHOWFIGS
   TWX_SHOWMINES
   TWX_SHOWPORT
   TWX_SHOWSECTOR
   TWX_SHOWSPECIALPORT
   TWX_SHOWTRADERS
   TWX_STOPALL
   TWX_STOPALLFAST
   TWX_TOGGLEDEAF
   TWX_TOTALSCANNED



Script Commands


add



Purpose: Adds a value to a variable.

Syntax: add var {value}

var: The variable that will have its value added to.

{value}: The amount the variable will be increased by (must be a number).



Notes: This command is a typical way to perform basic mathematics within TWX script.

Since mathematical and logical operators were introduced in v2.00, it is also possible to add to a variable using the following method:

setVar $value ($value + 1)


Example:

# calculate exactly how many trips we're making
# and how much we're carrying on our last trip

setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
  setVar $lastTrip $holds
else
  add $trips 1
end




addMenu



Purpose: Adds a new TWX menu. This menu can be either an internal script menu or an addition to the TWX Terminal Menu.

Syntax: addMenu {parent} {name} {description} {hotkey} {reference} {prompt} {closeMenu}

{parent}: The name of the 'parent' menu this menu will be added to. If left blank, the menu will not be shown in the option list of any other menu in existance.

{name}: The name of the new menu being created.

{description}: The description of the menu being created. This description will be shown in the option list of the parent menu, and as a title for the new menu option list.

{hotkey}: The hotkey used to access this menu from it's parent menu.

{reference}: The script label reference to jump to when the new menu is activated.

{prompt}: The text to display inside the new menu prompt.

{closeMenu}: If TRUE, this menu will automatically close itself when it is activated. For sub-menus that contain their own list of options, this should always be set to FALSE.



Notes: TWX menus are a great way to configure scripts before they are run. Also, using this command it is possible to customise the TWX Terminal Menu and add your own options.

Every menu can have a near limitless number of options, and every option can link to a new menu.

Menus can be activated using the 'OpenMenu' command after they have been created.


Example:

addMenu "" "BuyDown" "BuyDown Settings" "." "" "Main" FALSE
addMenu "BuyDown" "GO" "GO!" "G" :Menu_Go "" TRUE
addMenu "BuyDown" "Product" "Product" "P" :Menu_Product "" FALSE
addMenu "BuyDown" "TurnLimit" "Turn limit" "T" :Menu_TurnLimit "" FALSE
addMenu "BuyDown" "Quantity" "Quantity" "U" :Menu_Quantity "" FALSE
addMenu "BuyDown" "Haggle" "Haggling" "H" :Menu_HaggleFactor "" FALSE

gosub :sub_SetMenu

openMenu "BuyDown"



and



Purpose: Performs a logical 'AND' on a variable.

Syntax: and var {value}

var: The variable to be operated on. The value in this variable must be either TRUE (1) or FALSE (0).

{value}: The value to be operated by. This value must be either TRUE (1) or FALSE (0).



Notes: This command is used internally by the compiler to allow conditions to work properly. Its use in conventional scripting is almost unheard of.

Example:




branch



Purpose: Tests a value and performs a conditional jump to a script label.

Syntax: branch {value} {label}

{value}: The value to be tested.

{label}: The script label to jump to if the value is FALSE (0)



Notes: This command is used internally by the compiler to allow conditions to work properly. Its use in conventional scripting is not required in any way - use the 'IF' macro instead.

Example:




clearAllAvoids



Purpose: Removes all sectors from TWX's internal Avoid list, which is used by getCourse, getDistance, getNearestWarps, and getAllCourses.

Syntax: clearAllAvoids

Notes: Since all of TWX's plots use the internal Avoid list, it's a good idea to clear any existing avoids if you do not want them taken into account, or if you are unsure which ones are set. Be aware that these Avoids are independant of the game's Avoids.

Example:

setAvoid $enemySector
getCourse $course CURRENTSECTOR STARDOCK
gosub :mowCourse
clearAllAvoids



clearAvoid



Purpose: Removes a single sector from TWX's internal Avoid list, which is used by getCourse, getDistance, getNearestWarps, and getAllCourses.

Syntax: clearAvoid {sector}

{sector}: The sector to remove from the internal Avoid list.

{sector}: The sector number to remove from the internal Avoid list.

Notes: Be aware that this command only removes Avoids from the internal list, and does not alter the Avoids set in the game itself.

Example:




clientMessage



Purpose: Broadcast a block of formatted text to all connected telnet terminals.

Syntax: clientMessage {value}

{value}: The message to display to all connected telnet terminals.



Notes: This command is a slightly bolder version of the 'Echo' command. It is useful for debugging or spitting out script messages. It is unfortunately not very tidy.

Example:

# don't run script without free cargo holds
if ($holds = 0)
  clientMessage "No free cargo holds!"
  halt
end



closeMenu



Purpose: Closes the open TWX menu.

Syntax: closeMenu

Notes: This command can be used to close the TWX Terminal Menu, or any other script menu that is currently open. Menus can be opened using the 'OpenMenu' command, and created with the 'AddMenu' command.

Example:




connect



Purpose: Connects TWX Proxy to a remote server.

Syntax: connect

Notes: This command is exactly the same as using the 'Connect' option from the TWX Terminal menu. It will connect TWX Proxy to the game server defined in the currently selected database.

Example:




cutText



Purpose: 'Cuts' a value out of a piece of text.

Syntax: cutText {value} var {start} {length}

{value}: The text to 'cut' a value out of.

var: The variable to hold the 'cut' value.

{start}: The starting index of the value to 'cut'.

{length}: The length of the value to 'cut'. If this length is longer than the end of the text being 'cut' from, the value will be 'cut' to the end of the text.



Notes: This command will copy a value out of a larger value. This is a very useful command when parsing text.

Example:

# get the name of a planet being landed on

getWord CURRENTLINE $ID 2
stripText $ID "#"
getWord CURRENTLINE $Sector 5
stripText $Sector ":"
getWordPos CURRENTLINE $Pos ": "
cutText CURRENTLINE $Name ($Pos + 2) 999



delete



Purpose: Deletes a file.

Syntax: delete {filename}

{filename}: The name of the file to be deleted.



Notes: This command will immediately delete the specified file. If the file does not exist, no error will be given.

Example:

# write dead-end list to a file

clientMessage "Querying..."
delete deadends.txt
setVar $i 1
:next

if (SECTOR.WARPS[$i][2] = 0)
  write "deadends.txt" $i
end
if ($i > SECTORS)
  halt
end
add $i 1
goto :next



disconnect



Purpose: Disconnects TWX Proxy from the remote server.

Syntax: disconnect

Notes: This command will immediately disconnect from the remote server. No reconnect will be attempted. This is exactly the same as using the 'Disconnect' option from the TWX Terminal Menu.

Example:




divide



Purpose: Performs mathematical division on a variable.

Syntax: divide var {value}

var: The variable to be divided.

{value}: The amount to divide the variable by.



Notes: This command is used internally by the compiler to perform division. It can also be called manually.

Note that all decimal values will be truncated to the nearest whole number.

Another way to perform division is like this:

setVar $value ($value / 50)


Example:

# calculate exactly how many trips we're making
# and how much we're carrying on our last trip

setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
  setVar $lastTrip $holds
else
  add $trips 1
end



echo



Purpose: Prints text to all connected telnet terminals.

Syntax: echo {values...}

{values...}: A series of values containing the text to be echoed.



Notes: This command is the primary way of displaying text in connected clients without sending it to the server. Using this command, you can output data from your script, create menus, etc.

Example:

# Get a product type using a menu

:GetProduct
echo "*" ANSI_15 "Select Product:" "**"
echo ANSI_11 "1 " ANSI_3 " - Fuel Ore*"
echo ANSI_11 "2 " ANSI_3 " - Organics*"
echo ANSI_11 "3 " ANSI_3 " - Equipment*"
getConsoleInput $Product SINGLEKEY

if ($Product <> 1) and ($Product <> 2) and ($Product <> 3)
  goto :GetProduct
end




fileExists



Purpose: Checks to see if a file exists.

Syntax: fileExists var {filename}

var: The variable to hold the result of the file check. This variable will be set to TRUE (1) if the file exists, or FALSE (0) if it does not.

{filename}: The name of the file to check.



Notes: This command is useful for finding out if a file exists before attempting to read from it.

Example:

# load bust list
if ($BustFile <> "")
  fileExists $exists $BustFile

  if ($exists)
    setArray $BustList SECTORS
    setVar $i 1
    read $BustFile $bust $i
    while ($bust <> EOF)
      setVar $BustList[$bust] 1
      add $i 1
      read $BustFile $bust $i
    end
  end
end



getAllCourses



Purpose: Creates a 2-dimensional array with all course plots and distances where the StartSector is the specified sector, and the EndSector is the 1st dimension index.

Syntax: getAllCourses {array} {sector}

{array}: The user-specified array to populate, and associated variable which will equal the static array's size. This need not pre-exist, and any existing values will be overwritten.

{sector}: The starting sector for all of the plots.

Notes: This is a useful command if you need multiple plots or distances from the same start sector. This command works comparably to getCourse. Be aware, the plots that are returned take into account any Avoids which may have been added to the internal Avoid list by the setAvoid command.

If you used this command with StarDock specified as the start sector, the first few array elements would be as follows:

$array[1] = the distance from SD to sector 1
$array[1][1] = the start sector (StarDock in this example)
$array[1][2] = the first hop in the course from StarDock to sector1
$array[1][3] = the second hop, and so on.
...
$array[2] = the distance from SD to sector 2
$array[2][1] = the start sector (StarDock again)
$array[2][2] = the first hop in the course from StarDock to sector2
... and so on.


Example:

# Locate all unfigged sectors 8 hops from Terra and show the course
setVar $hops 8
getAllCourses $courses 1
setVar $a 1
while ($a <= SECTORS)
	if ($courses[$a] = $hops) and ($figGrid[$a] = 0)
		echo "*" $a ", Course:"
		setVar $b 1
		while ($b <= ($courses[$a] + 1))
			echo "  " $courses[$a][$b]
			add $b 1
		end
	end
	add $a 1
end



getCharCode



Purpose: Retrieves an ASCII character code from a single-character value.

Syntax: getCharCode {char} resultVar

{char}: The character to get a code from. This must be a single character, it cannot be a block of text.

resultVar: A variable to hold the character code.



Notes: For more information on ASCII character conversions, look up 'ASCII chart' in an internet search engine.

Example:




getConsoleInput



Purpose: Get input from a connected terminal without sending it to the remote server.

Syntax: getConsoleInput var [singleKey?]

var: A variable to hold the retreived input.

[singleKey?]: If this is specified, the command will only expect single key input as opposed to an entire line of text.



Notes: This command will pause the script until text is received from one of the connected telnet terminals. It is a useful way of getting script parameters when a script is first started, and can also be used to create menus.

Execution of the script will be paused while this command is active. Closing of the menu created by the command will terminate the script.


Example:

# Get a product type using a menu

:GetProduct
echo "*" ANSI_15 "Select Product:" "**"
echo ANSI_11 "1 " ANSI_3 " - Fuel Ore*"
echo ANSI_11 "2 " ANSI_3 " - Organics*"
echo ANSI_11 "3 " ANSI_3 " - Equipment*"
getConsoleInput $Product SINGLEKEY

if ($Product <> 1) and ($Product <> 2) and ($Product <> 3)
  goto :GetProduct
end




getCourse



Purpose: Internally calculates a warp course using warp data in the TWX Proxy database.

Syntax: getCourse varspec {fromSector} {toSector}

varspec: A variable that will contain the results of the course plotting.

{fromSector}: The sector to plot the course from.

{toSector}: The sector to plot the course to.



Notes: This command will plot a warp course without the use of the remote server. Note that this can only be done if there is sufficient warp data to properly plot the course.

'varspec' will contain the length (number of hops) of the warp course between the two sectors. This variable will be transformed into a dynamic array holding in sequence every sector in the warp course, i.e:

getCourse $course 1 10

Would return:

$course = 2
$course[1] = 1
$course[2] = 2
$course[3] = 10


If the warp course could not be calculated, 'varspec' will be set to -1.


Example:

# plot and display a warp course

getInput $fromSector "Enter a sector to plot from"
getInput $toSector "Enter a sector to plot to"
getCourse $course $fromSector $toSector

setVar $i 0

while ($i <= course)
  echo $course[$i] " "
  add $i 1
end



getDate



Purpose: Retrieves the date and stores it in a variable.

Syntax: getDate var

var: A variable that will contain the current date.



Notes: This command will return the date in the current system format. Note that this date will vary depending upon your regional settings. For more flexibility when formatting your date, refer to the 'getTime' command.

Example:




getDistance



Purpose: Internally calculates the distance between two sectors through the use of the TWX Proxy Database.

Syntax: getDistance var {fromSector} {toSector}

var: A variable that will contain the distance between the two sectors.

{fromSector}: The sector to plot a course from.

{toSector}: The sector to plot a course to.



Notes: This command behaves exactly the same as the 'getCourse' command - it internally plots a warp course between two sectors. The difference is that this command will record only the distance between both sectors without saving the results of the course itself - this gives a marginal speed improvement.

If there is not enough warp data to plot between the two sectors, 'var' will be set to -1.


Example:




getFileList



Purpose: Populates a specified array with any files that match a specified Mask (like *.ts).

Syntax: getFileList {array} {Mask}

Notes: This command allows a script to inventory the TWX folder or a subfolder for filenames that match the Mask's search criteria, using ? and * wildcards as needed. A variable matching the array name will be created with the number of files found.

Example:

# Search the logs to find any Starports that have been initiated.
getFileList $logs "logs\*" & GAMENAME & ".log"
# if 20 files where found, the variable '$logs' now equals 20.
# $logs[1] is the 1st file name, $logs[2] the 2nd, and so on.
echo "*A total of " $logs " Logs found."
setVar $a 1
while ($a <= $logs)
	echo "**Now Searching file " $logs[$a] "..."
	readToArray "logs\" & $logs[$a] $linesArray
	setVar $b 1
	while ($b <= $linesArray)
		getWordPos $linesArray[$b] $pos "began construction!"
		if ($pos > 0)
			echo "*" $linesArray[$b]
			add $newPortCount 1
		end
		add $b 1
	end
	add $a 1
end
echo "**Complete, " $newPortCount " ports have been logged.*"



getInput



Purpose: Gets a line of text from the user.

Syntax: getInput var {prompt}

var: A variable to hold the line of text entered by the user.

{prompt}: The text to display above the input prompt.



Notes: This command is similar to getConsoleInput, although it automatically displays a message above the prompt and has no support for single-key input.

Execution of the script will be paused while this command is active. Closing of the menu created by the command will terminate the script.


Example:

# input parameters
getInput $sectorNumber2 "Enter other sector to SSM from"
getInput $holds "Enter max holds to steal"



getLength



Purpose: Retrieves the length of a block of text.

Syntax: getLength {text} var

{text}: The text to be tested for its length.

var: A variable to hold the length of the block of text.



Notes: This is a simple text parsing command that can be used to get the length of a variable or a block of text.

Example:




getMenuValue



Purpose: Retrieve the display value of an existing menu.

Syntax: getMenuValue {menuName} var

{menuName}: The name of the menu to fetch the value from.

var: A variable to hold the value from the menu.



Notes: This command will retrieve the display value of a menu that has either been created using the 'addMenu' command, or is a part of the TWX Terminal Menu.

To set the display value of a menu, use the 'setMenuValue' command.


Example:




getNearestWarps



Purpose: Populates a specified array with surrounding sectors, sorted by distance.

Syntax: getNearestWarps {array} {sector}

Notes: This command allows for simple Nearest-Item searches, without the need to create and maintain a breadth-first search structure. Be aware that this command takes into account any Avoids that may have been set using setAvoid. A variable matching the array name will be created with the size of the array, and the array will not necessarily have a size of Sectors.

Example:

# Find the closest figged sector
getNearestWarps $nearArray CURRENTSECTOR
setVar $i 1
while ($i <= $nearArray)
	setVar $focus $nearArray[$i]
	if ($figGrid[$focus] > 0)
		echo "*NearFig: " $i "*"
		return
	end
	add $i 1
end



getOutText



Purpose: Retrieve any outgoing text from TWX Proxy's outgoing buffer.

Syntax: getOutText var

var: A variable to hold the outgoing text.



Notes: This command is typically used after the triggering of a TextOutTrigger in order to retrieve the text being sent to the remote server. In any other situation, the outgoing buffer should contain no data.

Example:




getRnd



Purpose: Generate a random number within a specified range.

Syntax: getRnd var {lowestValue} {highestValue}

var: A variable to hold the random number.

{lowestValue}: The lowest possible value for the generated number.

{highestValue}: The highest possible value for the generated number.



Notes: For a good working example of this command, see 1_Scout.ts.

Example:





getScriptVersion



Purpose: Reports the version of the compiler used for a compiled script. (*.cts)

Syntax: getScriptVersion {filename} var

Notes: TWX Proxy 2.02 scripts report version 1, 2.03Beta reports version 2, 2.03Final reports version 3, 2.04 reports version 4.

Example:

# Check compiled script's version before opening
getScriptVersion "scripts/buydown.cts" $ver
if ($ver <> 4)
	echo "*You need to update the buydown.cts file*"
else
	load "scripts/buydown.cts"
end



getSector



Purpose: Retrieve the details of a specific sector from the TWX Proxy Database.

Syntax: getSector {index} var

{index}: The number of the sector to retrieve.

var: A variable-spec to hold the details of the sector being retrieved.



Notes: The storageVar will be segmented into several new variables by

the use of a decimal point. These new variables will be as follows:


.INDEX
.BEACON
.EXPLORED (equal to YES, NO, DENSITY, CALC)
.CONSTELLATION
.ARMIDMINES.QUANTITY
.LIMPETMINES.QUANTITY
.ARMIDMINES.OWNER
.LIMPETMINES.OWNER
.FIGS.QUANTITY
.FIGS.OWNER
.FIGS.TYPE (equal to TOLL, OFFENSIVE, DEFENSIVE)
.UPDATED
.WARPS
.DENSITY
.ANOMOLY (equal to YES, NO)
.NAVHAZ
.WARP[1]
.WARP[2]
.WARP[3]
.WARP[4]
.WARP[5]
.WARP[6]
.PORT.NAME
.PORT.CLASS

.PORT.EXISTS (equal to 1 or 0)
.PORT.BUILDTIME
.PORT.PERC_ORE
.PORT.PERC_ORG
.PORT.PERC_EQUIP
.PORT.ORE
.PORT.ORG
.PORT.EQUIP
.PORT.UPDATED
.PORT.BUY_ORE (equal to YES, NO)
.PORT.BUY_ORG (equal to YES, NO)
.PORT.BUY_EQUIP (equal to YES, NO)

.PLANETS
.PLANET[x] (where x = a number from 1 to .PLANETS)

.TRADERS
.TRADER[x].NAME (where x = a number from 1 to .TRADERS)

.TRADER[x].SHIPNAME (where x = a number from 1 to .TRADERS)
.TRADER[x].SHIP (where x = a number from 1 to .TRADERS)
.TRADER[x].FIGS (where x = a number from 1 to .TRADERS)

.SHIPS
.SHIP[x].NAME (where x = a number from 1 to .SHIPS)
.SHIP[x].SHIP (where x = a number from 1 to .SHIPS)
.SHIP[x].OWNER (where x = a number from 1 to .SHIPS)

.SHIP[x].FIGS (where x = a number from 1 to .SHIPS)

.BACKDOORS[x]


They can be referenced by VARIABLE.VALUE, for instance:

$sector.warps

Also, this command will not work with recording disabled, as it
makes use of the sector database to obtain the information it
needs. If this information is not available, the output could be
misleading


Example:

# write dead-end list to a file

clientMessage "Querying..."
delete deadends.txt
setVar $i 1
:next

getSector $i $i
if ($i.warp[2] = 0)
  write "deadends.txt" $i
end
if ($i > SECTORS)
  halt
end
add $i 1
goto :next



getSectorParameter



Purpose: Retrieves a permanent user specified variable that has been assigned to a sector in the TWX Database.

Syntax: getSectorParameter {sectorIndex} {parameterName} var

{sectorIndex}: The index of the sector holding the value to retrieve.

{parameterName}: The search name of the value to retrieve. This can be anything up to 10 characters.

var: A variable to contain the value being retrieved.



Notes: This command can be used to return a value that has been assigned to a sector using the SetSectorParameter command.

If the value is not found, nothing ("") is returned.

For more information, refer to the SetSectorParameter command.


Example:

# show all sectors that have been marked as enemy territory

setVar $i 1

while ($i <= SECTORS)
  getSectorParameter $i "Owner" $owner

  if ($owner = "Enemy")
    echo $i "*"
  end
end



getText



Purpose: Copies a value out of a line of text by using sub strings.

Syntax: getText {line} var {startValue} {endValue}

{line}: The line of text to copy a value from.

var: A variable to store the value in.

{startValue}: A value within the line of text of which the ending point marks the beginning of the copied value.

{endValue}: A value within the line of text of which the beginning point marks the end of the copied value.



Notes: This command is a quick and easy way to snatch a value out of the CURRENTLINE after a TextLineTrigger has triggered. If you know of two blocks of text within the line, you can copy out the area of text between them using this command.

Example:

setVar $line "This is a test line to copy text from"
getText $line $value "line to " " text from"

# displays: "copy"
echo $value



getTime



Purpose: Retrieves the current system time, or a formatted value containing the time and/or date.

Syntax: getTime var [{format}]

var: A variable to hold the formatted time or date.

[{format}]: The format in which to return the time/date. If this is not specified, the variable will be set to hold the current system time in its default format.



Notes: This is an extemely powerful date/time formatting command.

Some components of the 'format' command are:

"d" : Displays the day of the month without a leading zero.
"dd" : Displays the day of the month with a leading zero.
"m": Displays the month without a leading zero.
"mm": Displays the month with a leading zero.
"yy": Displays a two digit year.
"yyyy": Displays a four digit year.

"h": Displays the hour without a leading zero.
"hh": Displays the hour with a leading zero.
"n": Displays the minute without a leading zero.
"nn": Displays the minute with a leading zero.
"s": Displays the second without a leading zero.
"ss": Displays the second with a leading zero.

"am/pm": Displays "am" or "pm" depending upon the time.
"a/p": Displays "a" or "p" depending upon the time.

"c": Displays the date in its system date format.
"t": Displays the time in its system time format.

Any characters within quotes are left as they are (without formatting). Unidentified components are simply shown as-is.


Example:

getTime $test "'The time is :' h:m:s, ' the date is :' d:m:yyyy'"

# displays: The time is : 12:22:28,  the date is : 11:4:2003
echo $test



getTimer



Purpose: Retrieves the Time Stamp Counter (RDTSC), which is the number of CPU ticks since power on.

Syntax: getTimer var

var: A variable to hold the tick count.

Notes: The result of this command is a 64-bit Integer. To measure the duration of an event in seconds, you will need to know the CPU speed in Hz. To simply compare routines to see which is faster, there is no reason to do the conversion to seconds. Merely get the duration for the first routine, then for the second routine, and whichever has the smaller number of Ticks for the interval is the faster routine.

Example:

getTimer $startTicks
# Perform some routine here
getTimer $stopTicks
setVar $durationTicks ($stopTicks - $startTicks)

# Now divide by CPU Hz if you need to convert Ticks to seconds. (2.2 GHz here)
# You will need to set the precision according to your desired accuracy, before dividing.
setPrecision 18
setVar $seconds ($durationTicks / 2200000000)
setPrecision 0
echo "*Time lapse in Seconds: " $seconds "*"



getWord



Purpose: Copies a specific word out of a line of text.

Syntax: getWord {line} var {index} {default}

{line}: A line or block of text to copy a specific word from.

var: A variable to hold the copied word.

{index}: The number of the word to copy, counted from the left of the line.

{default}:



Notes: This command is easily the most heavily used text parsing command available in TWX Script. It can be used very effectively with a TextLineTrigger.

Example:

setVar $line "This is a line of text"
getWord $line $word 4

# displays: line
echo $word



getWordPos



Purpose: Finds the location of a value within a block of text.

Syntax: getWordPos {text} storageVar {subString}

{text}: A block of text to find a value in.

storageVar: A variable to hold the location of the value.

{subString}: The value to find.



Notes: This is a basic text parsing command that will find a value in a block of text. If the value is not found, "storagevar" will be set to "0".

Note that this command is not word specific - you can cut out parts of words or even spaces with it. ANY value within the block of text that matches the value searched for will be found. If there are several matches, only the first one will be returned.


Example:

setVar $line "This is a line of text"
getWordPos $line $pos "line"

# displays: 11
echo $pos



gosub



Purpose: Temporarily jumps to a block of code (or subroutine) with the ability to return to where it came from.

Syntax: gosub {label}

{label}: A label within the script to temporarily jump to.



Notes: This command works the same way as a "goto" command, although it has the ability to be sent back to where it came from through the use of a "return" command.

It is good practice to always make sure that you match every "gosub" with a "return". Otherwise, you could get a large build-up of subroutine calls that will eventually cause a stack overflow.


Example:

# gosub/return demo:

echo "This is a gosub/return demo.  I'm going to branch to a subroutine."
gosub :subroutine
echo "I've just returned from my subroutine"
halt

:subroutine
echo "I'm in my subroutine"
return



goto



Purpose: Jumps to a different area within the script.

Syntax: goto {label}

{label}: A label within the script to jump to.



Notes: This command will immediately jump execution of the script to a label anywhere within the script or its included routines.

Example:

# Goto example:

echo "About to jump to another part of my script"
goto :otherPart
echo "I should never execute this command"

:otherPart
echo "I've just jumped to a different part of my script"
halt



halt



Purpose: Immediately and unconditionally terminates the script.

Syntax: halt

Notes: This command will shut down the script immediately. All unsaved variables are lost, and all triggers are deactivated.

Example:




isEqual



Purpose: Compares two values to see if they are equal.

Syntax: isEqual var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".



Notes: "var" will be set to TRUE (1) if the values match, or FALSE (0) if they don't.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isGreater



Purpose: Compares two values to see if the first is greater than the second.

Syntax: isGreater var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".



Notes: "var" will be set to TRUE (1) if the first value is greater than the second, or FALSE (0) if it is not.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isGreaterEqual



Purpose: Compares two values to see if the first is greater than or equal to the second.

Syntax: isGreater var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".


Notes: "var" will be set to TRUE (1) if the first value is greater than or equal to the second, or FALSE (0) if it is not.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isLesser



Purpose: Compares two values to see if the first is less than the second.

Syntax: isLesser var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".


Notes: "var" will be set to TRUE (1) if the first value is less than the second, or FALSE (0) if it is not.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isLesserEqual



Purpose: Compares two values to see if the first is less than or equal to the second.

Syntax: isLesserEqual var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".
{value2}:



Notes: "var" will be set to TRUE (1) if the first value is less than or equal to the second, or FALSE (0) if it is not.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isNotEqual



Purpose: Compares two values to see if they are not equal.

Syntax: isNotEqual var {value1} {value2}

var: A variable to hold the result of the comparison.

{value1}: A value to compare.

{value2}: A value to be compared with "value1".



Notes: "var" will be set to FALSE (0) if the values match, or TRUE (1) if they don't.

This command is used internally by the compiler. Its use is not recommended, use the "IF" macro instead.


Example:




isNumber



Purpose: Tests a value to see if it is a valid number.

Syntax: isNumber storageVar {value}

storageVar: A variable to hold the result of the test.

{value}: The value to be tested.



Notes: "storageVar" will be set to TRUE (1) if "value" is a number, otherwise it will be set to FALSE (0).

It is often good practice to test values entered by the user if you expect them to be numeric.


Example:

:PlanetsPerSector
getInput $value "Enter number of planets per sector"
isNumber $test $value
if ($test = 0)
  echo ANSI_15 "**Value must be a number*"
  goto :PlanetsPerSector
end
setVar $build_planetsPerSector $value
saveVar $build_planetsPerSector




killAllTriggers



Purpose: Terminates all triggers in the script and its included subroutines.

Syntax: killAllTriggers

Notes: Be careful with this command, especially if you are writing a subroutine that may need to preserve triggers already existing when the subroutine was called. It is always better to specifically terminate triggers using the "killTrigger" command if you know the ones that are active, instead of just killing all of them.

A good example of where this command could be used is in the disconnection handler of a script. Scripts should terminate their triggers if they are disconnected from the server, as they will likely re-enter the game in a completely different state.


Example:




killTrigger



Purpose: Terminates a trigger.

Syntax: killTrigger {name}

{name}: The name of a trigger to terminate.



Notes: This command can be used to terminate any sort of script trigger (TextTrigger, TextLineTrigger, DelayTrigger, EventTrigger, TextOutTrigger, etc).

If the specified trigger doesn't exist, the script ignores the command and continues as normal.


Example:

# see if we have a planet scanner
setVar $scanner 0
send "i"
setTextLineTrigger 1 :HasScanner "Planet Scanner"
setTextTrigger 2 :DoneTest "Command [TL="
pause

:HasScanner
setVar $scanner 1
killTrigger 2

:DoneTest
killTrigger 1



killWindow



Purpose: Unloads a script window.

Syntax: killWindow {windowName}

{windowName}: The name of the window to remove.



Notes: This command is provided for backwards compatibility. There is currently no support for script windows in v2.00.

Example:




listActiveScripts



Purpose: Populates a user-specified array with a list of currently active scripts.

Syntax: listActiveScripts {ArrayName}

Notes: A variable matching the name of the array will be created to hold the count and size of the array. So if you named the array $array, then $array will equal the number of active scripts, $array[1] will be the name of the first script, $array[2] the second, and so on.

Example:

# Stop FastFoton.ts if it is running
listActiveScripts $scripts
setVar $a 1
while ($a <= $scripts)
	if ($scripts[$a] = "FastFoton.ts")
		stop $scripts[$a]
		return
	end
	add $a 1
end



listAvoids



Purpose: Populates a user-specified array with the list of sectors currently set on TWX's internal Avoid list.

Syntax: listAvoids {ArrayName}

Notes: A variable matching the name of the array will be created to hold the count and size of the array. So if you named the array $array, then $array will equal the number of Avoids, $array[1] will be the first avoid, $array[2] the second, and so on. Be aware that this is independant from any Avoids set in the game.

Example:

# Clear any avoid with our fig present
listAvoids $voids
setVar $a 1
while ($a <= $voids)
	setVar $focus $voids[$a]
	if ($figGrid[$focus] > 0)
		clearAvoid $focus
	end
	add $a 1
end



listSectorParameters



Purpose: Populates a user-specified array with the list of Sector Parameters that exist for the specified sector.

Syntax: listSectorParameters {sector} {ArrayName}

Notes: A variable matching the name of the array will be created to hold the count and size of the array. So if you named the array $array, then $array will equal the number of Sector Parameters, $array[1] will be the name of the first Sector Parameter, $array[2] the second, and so on.

Example:

# Delete all Sector Parameters from the Database
setVar $a 1
while ($a <= SECTORS)
	listSectorParameters $a $parms
	setVar $b 1
	while ($b <= $parms)
		setSectorParameter $parms[$b] ""
		add $b 1
	end
	add $a 1
end



load



Purpose: Loads a script from a file.

Syntax: load {scriptName}

{scriptName}: The name of a script to load.



Notes: This is exactly the same as the $SS TWX Terminal Menu function.

Example:




loadVar



Purpose: Loads a variable from a file automatically associated with the currently selected TWX Database.

Syntax: loadVar var

var: The name of a variable to load from file.



Notes: This command will load a variable from the .cfg file stored in parallel with TWX Proxy's .xdb files. It can be used for retrieving variables associated with a script's configuration, and is a very nice tool for menus.

If the variable is not saved, "var" will be set to "0".


Example:

# get defaults
loadVar $EvilSaved

if ($EvilSaved)
  loadVar $evil_stealFactor
  loadVar $evil_robFactor
  loadVar $evil_continue
  loadVar $evil_broadcast
  loadVar $evil_shipsetup
  loadVar $evil_haggle
else
  setVar $evil_stealFactor 30
  setVar $evil_robFactor 3
  setVar $evil_continue 1
  setVar $evil_broadcast 1
  setVar $evil_shipSetup ""
  setVar $evil_haggle 1

  saveVar $evil_stealFactor
  saveVar $evil_robFactor
  saveVar $evil_continue
  saveVar $evil_broadcast
  saveVar $evil_shipSetup
  saveVar $evil_haggle

  setVar $EvilSaved 1
  saveVar $EvilSaved
end




logging



Purpose: Disables or enables TWX Proxy's logging feature while the script is running.

Syntax: logging {value}

{value}: The value to define if logging is enabled in the script. This can be either "ON" or "OFF".



Notes: It is good practice to always turn off logging in any script that transfers large amounts of unnecessary data.

The logging setting is local to every active script. If there are any scripts running with it disabled, no data will be logged. Logging will always default to "ON".


Example:




lowerCase



Purpose: Converts all text within a variable to lower case.

Syntax: lowerCase var

var: A variable containing text to be converted to lower case.



Notes:

Example:




mergeText



Purpose: Concatenates two text values together to form one.

Syntax: mergeText {value1} {value2} var

{value1}: The value to form the first part of the merged value.

{value2}: The value to form the second part of the merged value.

var: A variable to hold the merged value.



Notes: This command is used internally by the compiler, its use within scripts is not recommended. A much more usable way of performing this is through the use of the "&" operator.

Example:




multiply



Purpose: Performs mathematical multiplication on a variable.

Syntax: multiply var {value}

var: The variable to be multiplied.

{value}: The amount to multiply the variable by.



Notes: This command is used internally by the compiler to perform multiplication. It can also be called manually.

Another way to perform multiplication is like this:

setVar $value ($value * 50)


Example:

# calculate exactly how many trips we're making
# and how much we're carrying on our last trip

setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
  setVar $lastTrip $holds
else
  add $trips 1
end



openMenu



Purpose: Activates an existing script menu or TWX Terminal Menu option.

Syntax: openMenu {name} {pause}

{name}: The name of an existing menu to activate.

{pause}: Optional 2nd parameter, must be 'TRUE' or 'FALSE'. A Value of 'FALSE' causes the menu to display but not pause.



Notes: This command will activate (or open) a script or TWX Terminal Menu option.

Menus can be created with the 'addMenu' command, and closed using the 'closeMenu' command.


Example:

openMenu TWX_LISTACTIVE FALSE

addMenu "" "BuyDown" "BuyDown Settings" "." "" "Main" FALSE
addMenu "BuyDown" "GO" "GO!" "G" :Menu_Go "" TRUE
addMenu "BuyDown" "Product" "Product" "P" :Menu_Product "" FALSE
addMenu "BuyDown" "TurnLimit" "Turn limit" "T" :Menu_TurnLimit "" FALSE
addMenu "BuyDown" "Quantity" "Quantity" "U" :Menu_Quantity "" FALSE
addMenu "BuyDown" "Haggle" "Haggling" "H" :Menu_HaggleFactor "" FALSE

gosub :sub_SetMenu

openMenu "BuyDown"



or



Purpose: Performs a logical 'OR' on a variable.

Syntax: or var {value}

var: The variable to be operated. The value in this variable must be either TRUE (1) or FALSE (0).

{value}: The value to be operated by. This value must be either TRUE (1) or FALSE (0).



Notes: This command is used internally by the compiler to allow conditions to work properly. Its use in conventional scripting is almost unheard of.

Example:




pause



Purpose: Pauses the script's execution, allowing it to wait for its triggers to activate.

Syntax: pause

Notes: There exist 3 ways to pause a script, these are:

"pause"
"waitFor"
"waitOn"

Pause is the most commonly used method. A script's triggers will not activate unless the script is paused and waiting. If a script becomes paused while no triggers are active, it will hang uselessly.


Example:

# see if we have a planet scanner
setVar $scanner 0
send "i"
setTextLineTrigger 1 :HasScanner "Planet Scanner"
setTextTrigger 2 :DoneTest "Command [TL="
pause

:HasScanner
setVar $scanner 1
killTrigger 2

:DoneTest
killTrigger 1



processIn



Purpose: Emulates incoming text from the remote server, activating matching Text and TextLine triggers.

Syntax: processIn processType {text}

processType: The level of which to process the incoming data. A level of '0' will mean only triggers within the script can activate - a level of '1' will activate all matching triggers in ALL scripts.

{text}: The trigger text to emulate.



Notes: This command is still under development and not completely functional. Use is not recommended.

Example:




processOut



Purpose: Resumes processing out outgoing data that was trapped by a TextOutTrigger.

Syntax: processOut {text}

{text}: The data to process.



Notes: Any outgoing text that is caught by a TextOutTrigger is taken out of the outgoing buffer by the "getOutText" command. This command will return it to the buffer so that it can be processed by other scripts and/or sent to the remote server.

It is often a bad idea to send trapped outgoing data directly to the server using the "send" command. This is because in doing so, you prevent any other active scripts from trapping the same data when it is sent out.


Example:




read



Purpose: Reads a line of a text from a text file.

Syntax: read {file} storageVar {line}

{file}: The file to read text from.

storageVar: The variable to store the line in.

{line}: The line number to read.



Notes: This command attempts to read a line of text from a file. If the file does not exist, an error is raised. If the line is past the end of the file, 'EOF' is returned.

Example:

# load bust list
if ($BustFile <> "")
  fileExists $exists $BustFile

  if ($exists)
    setArray $BustList SECTORS
    setVar $i 1
    read $BustFile $bust $i
    while ($bust <> EOF)
      setVar $BustList[$bust] 1
      add $i 1
      read $BustFile $bust $i
    end
  end
end



readToArray



Purpose: Reads a text file directly into a TWX array.

Syntax: readToArray {file} storageArray

{file}: The file to read text from.

storageArray: The TWX Array to store the strings in.



Notes: This command is especially useful when reading in large text files, especially those greater than 10K lines. The array will be created and populated in one step. Any existing array with the same name will first be overwritten. Also, a variable with the same name as the array will be created, and its integer value will be the the element count of the array.

Example:

# Read a text file into an array
readToArray figlist.txt $figArray
# A variable $figArray also exists, and is equal to the element count
echo "*Figged Sectors read:" $figArray
setVar $i 1
while ($i <= $figArray)
	echo "*" $figArray[$i]
	add $i 1
end



rename



Purpose: Renames a file.

Syntax: rename {oldfile} {newfile}

{oldfile}: The file name of the file to rename.

{newfile}: The new name of the renamed file.



Notes: This command will give a file a new name. If the file does not exist, or another file exists under the new name, an error is raised.

To check if a file already exists, use the "fileExists" command.


Example:




replaceText



Purpose: Replaces a value, or set of values within a variable.

Syntax: replaceText var {oldText} {newText}

var: A variable containing the text to be replaced.

{oldText}: The text to be replace.

{newText}: The text to replace the old text with.



Notes: This command will scan through the contents of "var" replacing any text with that which is specified.

This command is extremely useful when text parsing - you can cut out uncertain characters in a block of text by converting them to spaces (or nothing), then extract the data you want using "getWord".


Example:




reqRecording



Purpose: Ensures that data recording is turned ON.

Syntax: reqRecording

Notes: This command will immediately terminate the script with a message if recording is turned off.

It is good practice to always use this command in any script that makes use of the "getSector" command or interfaces with the TWX Database in any way.


Example:




return



Purpose: Return from a subroutine.

Syntax: return

Notes: Use this command to return from a subroutine called by the "gosub" command.

If this command is used from outside a "gosub" subroutine, an error will occur.


Example:

# gosub/return demo:

echo "This is a gosub/return demo.  I'm going to branch to a subroutine."
gosub :subroutine
echo "I've just returned from my subroutine"
halt

:subroutine
echo "I'm in my subroutine"
return



round



Purpose: Rounds a variable to the specified precision.

Syntax: round var {precision}

Notes: This command will round the value held in specified variable to a specified number of decimal places. It is only really useful when used in combination with the setPrecision command.

Example:

setPrecision 2
setVar $x "500.52"
round $x 1

# this line will display: 500.5
echo $x



saveVar



Purpose: Saves a variable to a file automatically associated with the currently selected TWX Database.

Syntax: saveVar var

var: The name of a variable to save to file.



Notes: This command will save a variable to the .cfg file held in parallel with TWX Proxy's .xdb database files. Variables can be stored and retreived at any time, but must be under the same name.

To load a variable, use the "loadVar" command.


Example:

# get defaults
loadVar $EvilSaved

if ($EvilSaved)
  loadVar $evil_stealFactor
  loadVar $evil_robFactor
  loadVar $evil_continue
  loadVar $evil_broadcast
  loadVar $evil_shipsetup
  loadVar $evil_haggle
else
  setVar $evil_stealFactor 30
  setVar $evil_robFactor 3
  setVar $evil_continue 1
  setVar $evil_broadcast 1
  setVar $evil_shipSetup ""
  setVar $evil_haggle 1

  saveVar $evil_stealFactor
  saveVar $evil_robFactor
  saveVar $evil_continue
  saveVar $evil_broadcast
  saveVar $evil_shipSetup
  saveVar $evil_haggle

  setVar $EvilSaved 1
  saveVar $EvilSaved
end




send



Purpose: Sends text to the remote server.

Syntax: send {values...}

{values...}: A series of variables or values to be concatenated and sent to the server.



Notes:

Example:




setArray



Purpose: Declares a static array.

Syntax: setArray var {dimensions...}

var: A variable to define as an array.

{dimensions...}: A series of values defining the size of the array.



Notes: When a static array is defined, all its values are automatically set to "0".

Static arrays perform MUCH faster than TWX Proxy's dynamic arrays. Use them whenever possible.


Example:

# load bust list
if ($BustFile <> "")
  fileExists $exists $BustFile

  if ($exists)
    setArray $BustList SECTORS
    setVar $i 1
    read $BustFile $bust $i
    while ($bust <> EOF)
      setVar $BustList[$bust] 1
      add $i 1
      read $BustFile $bust $i
    end
  end
end



setAvoid



Purpose: Adds an Avoid to TWX's internal Avoid list.

Syntax: setAvoid {sector}

Notes: TWX's internal Avoid list is used by getCourse, getDistance, getNearestWarps, and getAllCourses. These Avoids are completely independant of the games Avoids.

Example:

# One way of showing the backdoor to Stardock
setVar $a 1
while ($a <= SECTOR.WARPCOUNT[STARDOCK])
	# Avoids warps out of StarDock
	setAvoid SECTOR.WARPS[STARDOCK][$a]
	add $a 1
end
getCourse $course 1 STARDOCK
if ($course = 0)
	echo "*No Backdoor found.*"
else
	# $course is the number of hops. Since the $course array
	# is $hops + 1, it is also the next-to-last warp
	echo "*Backdoor: " $course[$course]
end



setDelayTrigger



Purpose: Creates a trigger that will automatically activate after a specified time period.

Syntax: setDelayTrigger {name} {label} {tics}

{name}: The name of the trigger to create. This name is used for later references to the trigger.

{label}: A label within the script to jump to when the trigger is activated.

{tics}: The number of milliseconds to wait before the delay trigger automatically activates itself.



Notes: Triggers mark the way in which TWX Scripts interact with their environment (Trade Wars).

The delay trigger will automatically jump to a label within the script and begin executing as soon as a certain time period has elapsed.

Note that no triggers will activate unless the script has been paused with a "pause", "waitFor" or "waitOn" command.


Example:

:wait
send "#"
setDelayTrigger delay :wait 60000
pause



setEventTrigger



Purpose: Creates a trigger that will activate on a certain program event.

Syntax: setEventTrigger {name} {label} {event} [{parameter}]

{name}: The name of the trigger to create. This name is used for later references to the trigger.

{label}: A label within the script to jump to when the trigger is activated.

{event}: The name of the program event to attach the trigger to (see below).

[{parameter}]: Some (but not all) program events require parameters. These are specified here.



Notes: Triggers mark the way in which TWX Scripts interact with their environment (Trade Wars).

The event trigger will automatically jump to a label within the script and start executing as soon as a program event occurs matching its specification.

Currently, TWX Proxy supports the following program events and their parameters:

SCRIPT LOADED : Activates when a script is loaded. Its parameter is the name of the script loaded.

SCRIPT STOPPED : Activates when a script is terminated. Its parameter is the name of the script terminated.

CONNECTION ACCEPTED : Activates when TWX Proxy connects to the remote server (no parameters).

CONNECTION LOST : Activates when TWX Proxy disconnects from the remote server (no parameters).

CLIENT CONNECTED : Activates when a telnet client connects to TWX Proxy (no parameters).

CLIENT DISCONNECTED : Activates when a telnet client disconnects from TWX Proxy (no parameters).

TIME HIT : Activates when the click hits a certain time. Its parameter is the specified time in system format.


Note that no triggers will activate unless the script has been paused with a "pause", "waitFor" or "waitOn" command.


Example:




setMenuHelp



Purpose: Sets the help display of an existing menu.

Syntax: setMenuValue {menuName} {value}

{menuName}: The name of the menu to have its value set.

{value}: The new help text for the menu.



Notes: This command will set the help text displayed when a user requests help on a particular menu option. The menu must have been created using the 'addMenu' command, or be a member of the TWX Terminal Menu.

Example:




setMenuOptions



Purpose: Configures standard options accessible from a menu.

Syntax: setMenuOptions {menuName} {Q} {?} {+}

{menuName}: The name of the menu to have its options configured.

{Q}: Defines if the "Exit Menu" function will be accessible from within the specified menu. Valid options are TRUE (1) and FALSE (0).

{?}: Defines if the "Command List" function will be accessible from within the specified menu. Valid options are TRUE (1) and FALSE (0).

{+}: Defines if the "Help on Command" function will be accessible from within the specified menu. Valid options are TRUE (1) and FALSE (0).



Notes: This command can be used to enable or disable the default options supplied to a menu when it is first created. By default, all of these options are turned on.

Example:




setMenuValue



Purpose: Sets the display value of an existing menu.

Syntax: setMenuValue {menuName} {value}

{menuName}: The name of the menu to have its value set.

{value}: The new value that will be associated with the menu.



Notes: This command will set the display value of a menu that has either been created using the 'addMenu' command, or is part of the TWX Terminal Menu.

To get the display value of a menu, use the 'getMenu' command.


Example:

:sub_SetMenu
  if ($evil_haggle)
    setMenuValue "Haggling" "ON"
  else
    setMenuValue "Haggling" "OFF"
  end

  if ($evil_continue > 0)
    setMenuValue "Continue" "YES"
  else
    setMenuValue "Continue" "NO"
  end

  if ($evil_broadcast > 0)
    setMenuValue "Broadcast" "YES"
  else
    setMenuValue "Broadcast" "NO"
  end

  setMenuValue "StealFactor" $evil_stealFactor
  setMenuValue "RobFactor" $evil_robFactor
  setMenuValue "ShipSetup" $evil_shipSetup
  setMenuValue "QuickSetup" $evil_shipSetup
  return




setPrecision



Purpose: Sets the maximum precision for decimal calculations.

Syntax: setPrecision {value}

value: The new precision limit for decimals used during script interpretation.


Notes: This command is used to enable decimal calculations within TWX script.

By default, the decimal precision within a script is set to 0, this is to maintain backwards compatibility with older scripts that do not take decimal mathematics into consideration.

TWX Proxy supports decimal precision of up to 20 significant digits from calculations.

Once the precision has been set, all math performed will take into account the new precision and try to round all resulting values towards it. There is no limit to the number of times the precision can be changed within a script - in some cases it can be useful to adjust it for specific scenarios or subroutines.


Example:

# This will set precision to a max of 10 decimal places
setPrecision 10



setProgVar



Purpose: Sets a program variable.

Syntax: setProgVar {varName} {value}

{varName}: The name of the program variable to be set.

{value}: The value to store in the variable.



Notes: This command is provided for backwards compatibility only. It has no implementation. TWX Proxy v2.00 currently has no support for program variables.

Example:




setSectorParameter



Purpose: Sets a permanent variable in the TWX Database, assigning it to a sector.

Syntax: setSectorParameter {sectorIndex} {parameterName} {value}

{sectorIndex}: The index of the sector to hold the value.

{parameterName}: A name identifying the value to allow it to be retrieved later. This can be anything up to 10 characters long.

{value}: The value to store. This can be anything up to 40 characters long.


Notes: Use this command if you need to store an extra sector-specific value in the database (for example, a notation indicating which sectors belong to an enemy player).

The value assigned to the sector can be any length up to 40 characters. A sector can in theory have any number of values assigned to it. These values can be stored and retrieved from any script that works using the selected database.

Be extremely careful how many values you store against sectors. The method used to store and retrieve these values is not very efficient and will cause performance problems if the search list of total values is too large. A large number of these values can also cause the database to bloat and make it less efficient.

Values can be retrieved using the GetSectorParameter command.


Example:

# set the current sector as being enemy territory
setTextLineTrigger getSector :getSector "Sector  : "
pause
:getSector
getWord CURRENTLINE $sector 3
setSectorParameter $sector "Owner" "Enemy"



setTextLineTrigger



Purpose: Creates a trigger that will activate when a full line of text containing a specific value has been received from the remote server.

Syntax: setTextLineTrigger {name} {label} [{value}]

{name}: The name of the trigger to create. This name is used for later references to the trigger.

{label}: A label within the script to jump to when the trigger is activated.

[{value}]: A block of text that is required to be in the line for the trigger to activate. If this parameter is not specified, the trigger will activate on any line - even if it is blank.



Notes: Triggers mark the way in which TWX Scripts interact with their environment (Trade Wars).

The TextLine trigger will automatically jump to a label within the script and begin executing as soon as text is received from the remote server matching a certain requirement. Note that this text is case sensitive.

TextLine triggers differ from text triggers in that they will not activate unless a full line of text has been received. This makes them the standard for parsing data from the remote server.

Note that no triggers will activate unless the script has been paused with a "pause", "waitFor" or "waitOn" command.


Example:

# see if we have a planet scanner
setVar $scanner 0
send "i"
setTextLineTrigger 1 :HasScanner "Planet Scanner"
setTextTrigger 2 :DoneTest "Command [TL="
pause

:HasScanner
setVar $scanner 1
killTrigger 2

:DoneTest
killTrigger 1



setTextOutTrigger



Purpose: Creates a trigger that will activate when certain text is received from one of TWX Proxy's telnet clients.

Syntax: setTextOutTrigger {name} {label} [{value}]

{name}: The name of the trigger to create. This name is used for later references to the trigger.

{label}: A label within the script to jump to when the trigger is activated.

[{value}]: A value that must be matched with the outgoing text for the trigger to activate.



Notes: Triggers mark the way in which TWX Scripts interact with their environment (Trade Wars).

The TextOut trigger will automatically jump to a label within the script and begin executing as soon as text is received from a client terminal containing the specified value. The outgoing text will be stored within a buffer and can be retrieved using the "getOutText" command. After a TextOut trigger has been activated, the original outgoing text is held and will not be sent until it is passed to a "processOut" command.

Note that no triggers will activate unless the script has been paused with a "pause", "waitFor" or "waitOn" command.


Example:




setTextTrigger



Purpose: Creates a trigger that will activate when a text containing a specific value has been received from the remote server.

Syntax: setTextTrigger {name} {label} [{value}]

{name}: The name of the trigger to create. This name is used for later references to the trigger.

{label}: A label within the script to jump to when the trigger is activated.

[{value}]: A value that is required to be in the block of incoming text for the trigger to activate. If this parameter is not specified, the trigger will activate on any line - even if it is blank.



Notes: Triggers mark the way in which TWX Scripts interact with their environment (Trade Wars).

The Text trigger will automatically jump to a label within the script and begin executing as soon as text is received from the remote server matching a certain requirement. Note that this text is case sensitive.

Because the Text trigger can technically activate when only half a line of text has been received, it is usually bad practice to use it to extract data from the remote server. Use a TextLineTrigger instead.

Note that no triggers will activate unless the script has been paused with a "pause", "waitFor" or "waitOn" command.


Example:

# see if we have a planet scanner
setVar $scanner 0
send "i"
setTextLineTrigger 1 :HasScanner "Planet Scanner"
setTextTrigger 2 :DoneTest "Command [TL="
pause

:HasScanner
setVar $scanner 1
killTrigger 2

:DoneTest
killTrigger 1



setVar



Purpose: Sets the value of a variable.

Syntax: setVar var {value}

var: The name of the variable to set.

{value}: The value to place into the variable.



Notes:

Example:

# calculate exactly how many trips we're making
# and how much we're carrying on our last trip

setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
  setVar $lastTrip $holds
else
  add $trips 1
end



setWindowContents



Purpose: Sets the display content of a script window.

Syntax: setWindowContents {windowName} {value}

{windowName}: The name of the script window to have its contents set.

{value}: The text content to place inside the script window.



Notes: Sets the text content of a script window. The window must have been created using the 'window' command. To allow for multiple lines to be shown in the window, use the "*" value as used for the send/echo commands.

Example:

# Create ZTM progress window - as managed in 1_ZTM.ts
window ztm 170 94 "ZTM" ONTOP
setWindowContents ztm "Perc Done:*Est Time:*Speed:*Up to:"




sound



Purpose: Plays a sound (.WAV) file.

Syntax: sound {filename}

{filename}: The full relative path and name of a .wav file to play.



Notes: Playing a sound file will temporarily pause script execution - be careful not to play long sound files in combat situations as this may effect your play. However, this is a great way to give warning signals if you are asleep or away from the keyboard.

Example:

# play a sound
sound click.wav



stop



Purpose: Terminates an active script.

Syntax: stop {scriptName}

{scriptName}: The file name of the active script to terminate (not case sensitive).



Notes: This command will terminate the first script currently being executed by TWX Proxy with a name that matches the one specified. The specified script name does not require the extension (.ts or .cts) of the target script, nor its file path.

Example:

# load then terminate keepalive script (completely useless)
load 1_keepalive
stop 1_keepalive



stripText



Purpose: Removes a character or sub-string from a variable.

Syntax: stripText var {value}

var: A variable containing a text value to have certain characters or sub-strings to be removed.

{value}: The character or sub-string to strip from "var".



Notes: This command will remove ALL text matching "value" from the specified variable. This is a useful way to filter out unnecessary characters if you are trying to extract data from text received from the remove server.

Example:

# stripText example:

setVar $value "This is my value"
stripText $value "my "

# displays: This is value
echo $value



subtract



Purpose: Subtracts a value from a variable.

Syntax: subtract var {value}

var: The variable that will be subtracted from.

{value}: The amount the variable will be subtracted by (must be a number).



Notes: This command is a typical way to perform basic mathematics within TWX script.

Since mathematical and logical operators were introduced in v2.00, it is also possible to subtract from a variable using the following method:

setVar $value ($value - 1)


Example:

# calculate exactly how many trips we're making
# and how much we're carrying on our last trip

setVar $trips $quantity
divide $trips $holds
setVar $x $trips
multiply $x $holds
setVar $lastTrip $quantity
subtract $lastTrip $x
if ($lastTrip = 0)
  setVar $lastTrip $holds
else
  add $trips 1
end



systemScript



Purpose: Sets the script to become a "systemScript", allowing it to run in the background without the ability for it to be quick-terminated.

Syntax: systemScript

Notes: System scripts cannot be terminated by the "Stop all scripts" TWX Terminal Menu options. This makes them useful as keepalive, control or monitor scripts.

Example:




upperCase



Purpose: Converts all text within a variable to upper case.

Syntax: upperCase var

var: A variable containing the text to be converted to upper-case.



Notes:

Example:




waitFor



Purpose: Pauses script execution, waiting for a certain string of text from the remote server before continuing.

Syntax: waitFor {value}

{value}: The value to wait for.



Notes: If a trigger activates while this command is active, the command is immediately forgotten.

There is no reason why this command should be used instead of a trigger, except for the fact that it is easier to manage.


Example:

waitfor "(ENTER for none):"
send LoginName "*"
waitfor "Trade Wars 2002 Game Server"
send Game
waitfor "module now loading."
send "*t***" Password "*"



window



Purpose: Creates a script window to display information while the script is running.

Syntax: window {windowName} {sizeX} {sizeY} {title} [{ontop}]

{windowName}: The name of the script window to create. The window will in future be referenced by this name.

{sizeX}: The width (in pixels) of the new window.

{sizeY}: The height (in pixels) of the new window.

{title}: The title to display at the top of the window.

[{ontop}]: If specified, the window will be set to appear on top of all other windows on the desktop.



Notes: This is a very useful way to get information back from an active script without needing to dump it into a scrolling terminal. An example would be progress reports from a ZTM script.

Once a window has been created, its content can be modified with the 'setWindowContents' command. Terminating the script will automatically close the window.

Note that if you use of the "*" character in the window contents will create a new line in the window.


Example:

# Create ZTM progress window - as managed in 1_ZTM.ts
window ztm 170 94 "ZTM" ONTOP
setWindowContents ztm "Perc Done:*Est Time:*Speed:*Up to:"




write



Purpose: Appends a line of text to a text file.

Syntax: write {file} {value}

{file}: The name of a text file to append a line to.

{value}: The value to append to the file.



Notes: This command can be used to store a line of text at the end of a file. If the file does not exist, it is created.

Example:




xor



Purpose: Performs a logical 'XOR' on a variable.

Syntax: xor var {value}

var: The variable to be operated. The value in this variable must be either TRUE (1) or FALSE (0).

{value}: The value to be operated by. This value must be either TRUE (1) or FALSE (0).



Notes: This command is used internally by the compiler to allow conditions to work properly. Its use in conventional scripting is almost unheard of.

Example:




Script Macros


IF



Usage:

IF (expression)
  ...
ELSEIF
  ...
ELSE
  ...
END


Description:

This macro will write micro-commands to perform a standard 'if' comparison.  All the commands
under the 'IF' section of this structure will only be executed if the expression evaluates
to true.  The commands under the 'ELSEIF' will only be executed if the primary expression
results to false, and 'ELSEIF' expression results to true.  The commands under the 'ELSE'
structure will only be executed if no other part of the structure has been.


Example:

IF ($x = "Hello")
  echo "Hello there!"
ELSEIF ($x = "Bye")
  echo "Bye!"
ELSE
  echo "I didn't hear you!"
END



INCLUDE



Usage:

INCLUDE scriptname


Description:

This macro will include the code from another script or pack2 include file during compilation.


Example:

include "includemove"



WAITON



Usage:

WAITON text


Description:

This macro will write the commands to create a temporary TextTrigger.  This can be used as
a substitute for a waitFor command that will not be 'broken' if another trigger activates
while the script is waiting for text.


Example:

waitOn "Command [TL="



WHILE



Usage:

WHILE (expression)
  ...
END


Description:  This macro will create a standard 'while' loop.  All the commands within this
loop will continue to be repeated until the expression evaluates to false.


Example:

setVar $x 1
WHILE ($x < 10)
  echo "Counting: " & $x & "*"
  add $x 1
END



System Values


ALPHACENTAURI



Returns the sector in which the Class 0 - Alpha Centauri was last sighted.



ANSI_0



Returns the ANSI code for the colour black.



ANSI_1



Returns the ANSI code for the colour dark blue.



ANSI_10



Returns the ANSI code for the colour light green.



ANSI_11



Returns the ANSI code for the colour light cyan.



ANSI_12



Returns the ANSI code for the colour light red.



ANSI_13



Returns the ANSI code for the colour light purple.



ANSI_14



Returns the ANSI code for the colour light yellow.



ANSI_15



Returns the ANSI code for the colour white.



ANSI_2



Returns the ANSI code for the colour dark green.



ANSI_3



Returns the ANSI code for the colour dark cyan.



ANSI_4



Returns the ANSI code for the colour dark red.



ANSI_5



Returns the ANSI code for the colour dark purple.



ANSI_6



Returns the ANSI code for the colour dark yellow.



ANSI_7



Returns the ANSI code for the colour grey.



ANSI_8



Returns the ANSI code for the colour dark grey.



ANSI_9



Returns the ANSI code for the colour light blue.



CONNECTED



Returns TRUE (1) if TWX Proxy is connected to the remote server, or FALSE (0) if it is not.



CURRENTANSILINE



Returns the current line of text that is partway through processing, complete with any ANSI
codes in it.



CURRENTLINE



Returns the current line being processed from the game server.  In a normal situation, this
is the line that has just been triggered on.



CURRENTSECTOR



Returns the current sector as last seen at the Command prompt or Computer Command prompt.



DATE



Returns the current date in system format.



FALSE



Returns "0".



GAME



Returns the game letter as stored in the currently selected database.  This is usually used
by login scripts.



GAMENAME



Returns the name of the currently selected database.



LICENSENAME



Returns the user portion of the current registration.



LOGINNAME



Returns the login name as stored in the currently selected database.  This is usually used
by login scripts.



PASSWORD



Returns the user password as stored in the currently selected database.  This is usually used
by login scripts.



PORT.BUILDTIME[sector]



Returns the number of days remaining until port completion.  This figure is not updated, so
the SECTOR.UPDATED timestamp should be used as a reference.



PORT.BUYEQUIP[sector]



Returns TRUE (1) if the port in the specified sector buys equipment, or FALSE (0) if it does
not.



PORT.BUYFUEL[sector]



Returns TRUE (1) if the port in the specified sector buys fuel ore, or FALSE (0) if it does
not.



PORT.BUYORG[sector]



Returns TRUE (1) if the port in the specified sector buys organics, or FALSE (0) if it does
not.



PORT.CLASS[sector]



Returns the class of a port within a particular sector as stored in the TWX Proxy Database.



PORT.EQUIP[sector]



Returns the amount of onhand equipment in a port in a specified sector, as stored in the TWX
Proxy Database.



PORT.EXISTS[sector]



Returns TRUE (1) if a port exists in the specified sector, or FALSE (0) if it doesn't.



PORT.FUEL[sector]



Returns the amount of onhand fuel in a port in a specified sector, as stored in the TWX Proxy
Database.



PORT.NAME[sector]



Returns the name of the port in the specified sector.



PORT.ORG[sector]



Returns the amount of onhand organics in a port in a specified sector, as stored in the TWX
Proxy Database.



PORT.PERCENTEQUIP[sector]



Returns the onhand percentage of the maximum available equipment on a port, as stored in the
TWX Proxy Database.



PORT.PERCENTFUEL[sector]



Returns the onhand percentage of the maximum available fuel on a port, as stored in the TWX
Proxy Database.



PORT.PERCENTORG[sector]



Returns the onhand percentage of the maximum available organics on a port, as stored in the
TWX Proxy Database.



PORT.UPDATED[sector]



Returns the date and timestamp that a port was last updated in the database.



RAWPACKET



Returns the unaltered data received in the last transmission from the server.



RYLOS



Returns the sector in which the Class 0 - Rylos was last sighted.



SECTOR.ANOMOLY[sector]



Returns 1 (TRUE) if a sector was last recorded with an anomoly, or 0 (FALSE) if it wasn't.



SECTOR.BACKDOORCOUNT[sector]



Returns the number of one-way warps (backdoors) leading into a specific sector.



SECTOR.BACKDOORS[sector][index]



Returns a particular one-way warp (backdoor) into a specific sector.  There can be up to SECTOR.BACKDOORCOUNT[sector]
backdoors leading into one sector.



SECTOR.BEACON[sector]



Returns the name of the Beacon in the sector, if present.



SECTOR.CONSTELLATION[sector]



Returns the name of the nebulae of which the sector is a part.



SECTOR.DENSITY[sector]



Returns the density reading for a specific sector as stored in the TWX Proxy Database.



SECTOR.EXPLORED[sector]



Returns the explored status of a specific sector as stored in the TWX Proxy Database.  This
can be any one of the following:
"YES" : The sector has been seen with a holoscanner, a probe, or in person.
"DENSITY" : The sector has been seen with a density scanner only.
"CALC" : The sector has not been seen, but at least one warp has been calculated out of it
(ZTM).
"NO": The sector has not been explored or calculated in any way.



SECTOR.FIGS.OWNER[sector]



Returns the name of the owner of a group of fighters in a specific sector as stored in the
TWX Proxy Database.



SECTOR.FIGS.QUANTITY[sector]



Returns the number of fighters in a specific sector as stored in the TWX Proxy Database.



SECTOR.FIGS.TYPE[sector]



Returns the type of fighter present in the sector: Offensive, Defensive, or Toll.



SECTOR.LIMPETS.OWNER[sector]



Returns the owner of the limpet mines in a specific sector as stored in the TWX Proxy Database.



SECTOR.LIMPETS.QUANTITY[sector]



Returns the number of limpet mines in a specific sector as stored in the TWX Proxy Database.



SECTOR.MINES.OWNER[sector]



Returns the owner of armid mines in a specific sector as stored in the TWX Proxy Database.



SECTOR.MINES.QUANTITY[sector]



Returns the number of armid mines in a sector as stored in the TWX Proxy Database.



SECTOR.NAVHAZ[sector]



Returns the amount of navigational hazard in a sector as stored in the TWX Proxy Database.



SECTOR.PLANETCOUNT[sector]



Returns the number of planets in a specific sector as stored in the TWX Proxy Database.



SECTOR.PLANETS[sector][index]



Returns the name of a specific planet in a specific sector, as stored in the TWX Proxy Database.



SECTOR.SHIPCOUNT[sector]



Returns the number of ships in a specific sector as stored in the TWX Proxy Database.



SECTOR.SHIPS[sector][index]



Returns the name of a specific ship within a specific sector as stored in the TWX Proxy Database.



SECTOR.TRADERCOUNT[sector]



Returns the number of traders in a specific sector as stored in the TWX Proxy Database.



SECTOR.TRADERS[sector][index]



Returns the name of a specific trader within a specific sector as stored within the TWX Proxy
Database.



SECTOR.UPDATED[sector]



Returns the date and timestamp that a sector was last updated in the database.



SECTOR.WARPCOUNT[sector]



Returns the number of warps leading out of a specific sector as stored in the TWX Proxy Database.



SECTOR.WARPINCOUNT[sector]



Returns the number of warps leading into a specific sector as stored in the TWX Proxy Database.



SECTOR.WARPSIN[sector][index]



Returns a particular warp leading into a specific sector as stored in the TWX Proxy Database.



SECTOR.WARPS[sector][index]



Returns a particular warp leading out of a specific sector as stored in the TWX Proxy Database.



SECTORS



Returns the number of sectors in the currently selected database.



STARDOCK



Returns the sector in which the game's stardock was last sighted.



TIME



Returns the current time in system format.



TRUE



Returns "1".



Terminal Menu References


TWX_ACCEPTEXTERNAL



Represents the option to control external connections in the TWX setup menu.



TWX_BUBBLESIZE



Represents the option to adjust the maximum bubble size in the TWX setup menu.



TWX_BURST



Represents the burst option in the main TWX Terminal Menu.



TWX_CACHE



Represents the option to enable or disable the database cache, in the TWX setup menu.



TWX_CONNECT



Represents the connect/disconnect option in the main TWX Terminal Menu.



TWX_DATA



Represents the TWX data menu.



TWX_DATABASE



Represents the TWX database setup menu.



TWX_DATABASE_CREATE



Represents the option to a create a TWX database, in the TWX database setup menu.



TWX_DATABASE_DELETE



Represents the option to delete an existing TWX database, in the TWX database setup menu.



TWX_DATABASE_EDIT



Represents the option to edit an existing database, in the TWX database setup menu.



TWX_DATABASE_SELECT



Represents the option to select a specific database, in the TWX database setup menu.



TWX_DATABASE_VIEW



Represents the option to view the details of a specific database, in the TWX database setup
menu.



TWX_DUMPSCRIPTVARS



Represents the option to dump a list of all variables in use in every active script, in the
TWX script menu.



TWX_EDITBURST



Represents the edit burst option in the main TWX Terminal Menu.



TWX_EXIT



Represents the option to immediately terminate the program, in the main TWX Terminal Menu.



TWX_HOLOSCAN



Represents the option to simulate a holoscan, in the TWX data menu.



TWX_KILL



Represents the option to terminate a specific script, in the TWX script menu.



TWX_LISTACTIVE



Represents the option to list all active scripts, in the TWX script menu.



TWX_LISTDIRECTORY



Represents the option to list all the scripts in the script directory, in the TWX script menu.



TWX_LISTENPORT



Represents the option to configure the listening port in the TWX setup menu.



TWX_LISTPORTS



Represents the option to list all recorded ports, in the TWX port menu.



TWX_LISTUPGRADEDPORTS



Represents the option to list all upgraded ports, in the TWX port menu.



TWX_LOADLASTSCRIPT



Represents the option to load the last loaded script, in the TWX script menu.



TWX_LOADSCRIPT



Represents the option to load a script, in the TWX script menu.



TWX_LOCALECHO



Represents the option to enable or disable local echoing of outgoing data, in the TWX setup
menu.



TWX_LOG



Represents the option to enable or disable the logging of data received from the remote server,
in the TWX setup menu.



TWX_LOGANSI



Represents the option to log ANSI codes in the TWX setup menu.



TWX_MAIN



Represents the main TWX Terminal Menu.



TWX_PLOTCOURSE



Represents the option to plot a warp course between two sectors, in the TWX data menu.



TWX_PORT



Represents the TWX port menu.



TWX_RECONNECT



Represents the option to enable or disable automatic reconnection to the remote server, in
the TWX setup menu.



TWX_REPEATBURST



Represents the repeat burst option in the main TWX Terminal Menu.



TWX_SCRIPT



Represents the TWX script menu.



TWX_SCRIPTKEY



Represents the script menu created by the getConsoleInput command for single-key input.  For
internal use only - DO NOT open this menu.



TWX_SCRIPTTEXT



Represents an open menu created by the getInput or getConsoleInput command.  This is for internal
use only - DO NOT open this menu.



TWX_SETUP



Represents the TWX setup menu.



TWX_SHOWANOM



Represents the option to show all sectors with a reported anomoly, in the TWX data menu.



TWX_SHOWBACKDOORS



Represents the option to display backdoors to a specific sector, in the TWX data menu.



TWX_SHOWBUBBLE



Represents the option to calculate and display a specific bubble, in the TWX data menu.



TWX_SHOWBUBBLES



Represents the option to calculate and show bubbles, in the TWX data menu.



TWX_SHOWCLIENTS



Represents the option to display all connected clients, in the main TWX Terminal Menu.



TWX_SHOWDENSITY



Represents the option to show all sectors within a density range, in the TWX data menu.



TWX_SHOWFIGS



Represents the option to show all sectors with foreign fighters in them, in the TWX data menu.



TWX_SHOWMINES



Represents the option to show all sectors with mines in them, in the TWX data menu.



TWX_SHOWPORT



Represents the option to display a specific port, in the TWX port menu.



TWX_SHOWSECTOR



Represents the option to display a specific sector, in the TWX data menu.



TWX_SHOWSPECIALPORT



Represents the option to display all class 0/9 ports, in the TWX port menu.



TWX_SHOWTRADERS



Represents the option to show all sectors with traders in them, in the TWX data menu.



TWX_STOPALL



Represents the option to terminate all active scripts, in the TWX script menu.



TWX_STOPALLFAST



Represents the 'stop all scripts' option in the main TWX Terminal Menu.



TWX_TOGGLEDEAF



Represents the toggle deaf client function in the main TWX Terminal Menu.



TWX_TOTALSCANNED



Represents the option to display a summary of all sectors scanned, in the TWX data menu.