hxTorquescript Source

Run Torquescript on the Web!
Code
Output
Console
Input Torquescript compiled DSO
Disassembly
Code
Output

Console Functions


nameToId

nameToID(object) - Returns the id of the object

isObject

isObject(object) - Returns whether the object exists or not

cancelEvent

cancel(eventId) - Cancels a scheduled event

isEventPending

isEventPending(eventId) - Returns whether the given event is pending to be completed or not

schedule

schedule(time, refobject|0, command, ) - Schedules a function or method 'command' to be run after 'time' milliseconds with optional arguments and returns the event id

getSimTime

getSimTime() - Returns the milliseconds since the interpreter started

getRealTime

getRealTime() - Returns the milliseconds passed since unix epoch

expandFilename

expandFilename(filename) - Returns the full path of to the file

strcmp

strcmp(string one, string two) - Compares two strings using case-sensitive comparison.

stricmp

stricmp(string one, string two) - Compares two strings using case-insensitive comparison.

strlen

strlen(string) - Get the length of the given string in bytes.

strstr

strstr(string string, string substring) - Find the start of substring in the given string searching from left to right.

strpos

strpos(string hay, string needle, int offset) - Find the start of needle in haystack searching from left to right beginning at the given offset.

ltrim

ltrim(string value) - Remove leading whitespace from the string.

rtrim

rtrim(string value) - Remove trailing whitespace from the string.

trim

trim(string value) - Remove leading and trailing whitespace from the string.

stripChars

stripChars(string value, string chars) - Remove all occurrences of characters contained in chars from str.

strlwr

strlwr(string value) - Return an all lower-case version of the given string.

strupr

strupr(string value) - Return an all upper-case version of the given string.

strchr

strchr(string value, string char) - Find the first occurrence of the given character in str.

strreplace

strreplace(string source, string from, string to) - Replace all occurrences of from in source with to.

getSubStr

getSubStr(string str, int start, int numChars) - Return a substring of str starting at start and continuing either through to the end of str (if numChars is -1) or for numChars characters (except if this would exceed the actual source string length)

getWord

getWord(string str, int index) - Extract the word at the given index in the whitespace-separated list in text.

getWords

getWords(string str, int index, int endIndex = INF) = Extract a range of words from the given startIndex onwards thru endIndex.

setWord

setWord(text, index, replacement) - Replace the word in text at the given index with replacement.

removeWord

removeWord(text, index) - Remove the word in text at the given index.

getWordCount

getWordCount(string str) - Return the number of whitespace-separated words in text.

getField

getField(string str, int index) - Extract the field at the given index in the tab separated list in text.

getFields

getFields(string str, int index, int endIndex = INF) - Extract a range of fields from the given startIndex onwards thru endIndex.

setField

setField(text, index, replacement) - Replace the field in text at the given index with replacement.

removeField

removeField(text, index) - Remove the field in text at the given index.

getFieldCount

getFieldCount(string str) - Return the number of tab separated fields in text.

getRecord

getRecord(string str, int index) - Extract the record at the given index in the newline-separated list in text.

getRecords

getRecords(string str, int index, int endIndex = INF) - Extract a range of records from the given startIndex onwards thru endIndex.

setRecord

setRecord(text, index, replacement) - Replace the record in text at the given index with replacement.

removeRecord

removeRecord(text, index) - Remove the record in text at the given index.

getRecordCount

getRecordCount(string str) - Return the number of newline-separated records in text.

firstWord

firstWord(string str) - Return the first word in text.

restWords

restWords(string str) - Return all but the first word in text.

nextToken

nextToken(str, token, delim) - Tokenize a string using a set of delimiting characters.

detag

detag(textTagString) - Detag a given tagged string

getTag

getTag(textTagString) - Get the tag of a tagged string

activatePackage

activatePackage(package) - Activates an existing package.

deactivatePackage

deactivatePackage(package - Deactivates a previously activated package.

isPackage

isPackage(package) - Returns true if the package is the name of a declared package.

echo

echo(value, ...) - Logs a message to the console.

warn

warn(value, ...) - Logs a warning message to the console.

error

error(value, ...) - Logs an error message to the console.

expandEscape

expandEscape(text) - Replace all characters in text that need to be escaped for the string to be a valid string literal with their respective escape sequences.

collapseEscape

collapseEscape(text) - Replace all escape sequences in text with their respective character codes.

quit

quit() - Quit the interpreter program

compile

compile(fileName) - Compile a file to bytecode.

exec

exec(fileName) - Execute the given script file.

eval

eval(consoleString) - Evaluates the given string

trace

trace(bool) - Enable or disable tracing in the script code VM.

findFirstFile

findFirstFile(string pattern) - Returns the first file in the directory system matching the given pattern.

findNextFile

findNextFile(string pattern) - Returns the next file matching a search begun in findFirstFile().

getFileCount

getFileCount(string pattern) - Returns the number of files in the directory tree that match the given patterns.

isFile

isFile(fileName) - Determines if the specified file exists or not.

fileExt

fileExt(fileName) - Get the extension of a file.

fileBase

fileBase(fileName) - Get the base of a file name (removes extension).

fileName

fileName(fileName)- Get the file name of a file (removes extension and path).

filePath

filePath(fileName) - Get the path of a file (removes name and extension).

Math Functions


mSolveQuadratic

mSolveQuadratic(float a, float b, float c) - Solve a quadratic equation (2nd degree polynomial) of form a*x^2 + b*x + c = 0.

mSolveCubic

mSolveCubic(float a, float b, float c, float d) - Solve a cubic equation (3rd degree polynomial) of form a*x^3 + b*x^2 + c*x + d = 0.

mSolveQuartic

mSolveQuartic(float a, float b, float c, float d, float e) - Solve a quartic equation (4th degree polynomial) of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.

mFloor

mFloor(float v) - Round v down to the nearest whole number.

mCeil

mCeil(float v) - Round v up to the nearest whole number.

mAbs

mAbs(float v) - Returns the absolute value of the argument.

mSqrt

mSqrt(float v) - Returns the square root of the argument.

mPow

mPow(float b, float p) - Returns the b raised to the pth power.

mLog

mLog(float v) - Returns the natural logarithm of the argument.

mSin

mSin(float th) - Returns the sine of th, which is in radians.

mCos

mCos(float th) - Returns the cosine of th, which is in radians.

mTan

mTan(float th) - Returns the tangent of th, which is in radians.

mAsin

mAsin(float th) - Returns the arc-sine of th, which is in radians.

mAcos

mAcos(float th) - Returns the arc-cosine of th, which is in radians.

mAtan

mAtan(float rise, float run) - Returns the slope in radians (the arc-tangent) of a line with the given rise and run.

mRadToDeg

mRadToDeg(float radians) - Converts a measure in radians to degrees.

mDegToRad

mDegToRad(float degrees) - Convert a measure in degrees to radians.

SimObject

extends ConsoleObject

Methods

setName

obj.setName(newName) - Set the global name of the object.

getName

obj.getName() - Get the global name of the object.

getClassName

obj.getClassName() - Get the name of the engine class which the object is an instance of.

getId

obj.getId() - Get the underlying unique numeric ID of the object.

getGroup

obj.getGroup() - Get the group that this object is contained in.

delete

obj.delete() - Delete and remove the object.

schedule

object.schedule(time, command, ) - Delay an invocation of a method.

Inherited Methods

See ConsoleObject methods

ScriptObject

extends SimObject

Methods

Inherited Methods

See SimObject methods

SimDataBlock

extends SimObject

Methods

Inherited Methods

See SimObject methods

SimSet

extends SimObject

Methods

listObjects

set.listObjects() - Dump a list of all objects contained in the set to the console.

add

set.add(obj1,...) - Add the given objects to the set.

remove

set.remove(obj1,...) - Remove the given objects from the set.

clear

set.clear() - Remove all objects from the set.

getCount

set.getCount() - Get the number of objects contained in the set.

getObject

set.getObject(objIndex) - Get the object at the given index.

isMember

set.isMember(object) - Test whether the given object belongs to the set.

bringToFront

set.bringToFront(object)

pushToBack

set.pushToBack(object) - Make the given object the last object in the set.

Inherited Methods

See SimObject methods

SimGroup

extends SimSet

Methods

Inherited Methods

See SimSet methods