ScriptHook
The V2.00 ThereClient introduced a service specifically intended for use by other programs. These programs may be external to the ThereClient, or may execute within the ThereClient environment in the form of a customized replacement Flash movie. The primary difference between the two modes of operation is:
- A Flash movie within the ThereClient does not require activation of the SystemCockpit, but it can only be launched if
- its name matches one that is encoded into ThereClient
- it’s launched by a Flash movie already running in the ThereClient
- No such name restriction exists for programs running outside of the ThereClient, but the SystemCockpit must be manually enabled in order for them to work, and they will not automatically terminate when the ThereClient terminates.
Although the ScriptHook service was intended for use in automated testing of the ThereClient, it can be used by other applications in many ways. A ScriptHook service request looks like this:
http://localhost:9999/ScriptHook/
operation?Path=
path
This service allows you to manipulate a tree of nodes by specifying the node’s path and an operation to perform. Paths are similar to Unix file names in that they have multiple components separated by “/” characters, and the root of the tree is referred to as a path containing a single “/” character.
Each node has three elements:
- A version, containing a number which increments when the value of the node changes or a special flag value to indicate that versioning is not supported on this node. Unfortunately:
- We don’t know what the special flag value is.
- It is a known (and very low priority) bug that some nodes do not support versioning, but nevertheless just have a normal version number such as “1”. If you perform a
Wait
operation on such a node, it will never terminate.
- A type of either
Container
,Value
orMethod
. Value nodes and method nodes are the leaves of the tree, while container nodes make up the body of the tree. - The node’s value. For a container node, this is a list of the possible child nodes, either leaves or nested container nodes. For a method node, the arguments required to invoke the method are described.
The operation used for the service can be one of the following:
-
Browse
can be used to get an HTML view of the node. -
Get
provides an XML view of the node. -
Wait
(with an additional&Version=
ver parameter) allows you to perform aGet
but will not return until the version of the node is different from the provided ver parameter. -
Invoke
(with an additional&Args=
args parameter) allows a method node to be invoked. -
Set
(with an additional&Value=
v parameter) allows a value node to be set.
Value Nodes
If you perform a Get
or Wait
operation on a value node, you will see something like this:
http://localhost:9999/ScriptHook/Get?Path=/thobs/196772622/edprops/forcefield/value
<Answer>
<Result>1</Result>
<Node>
<Version>1</Version>
<Type>Value</Type>
<Value>0</Value>
</Node>
</Answer>
Container Nodes
If you perform a Get
or Wait
operation on a container node, you will see something like this:
http://localhost:9999/ScriptHook/Get?Path=/thobs/196772622
<Answer>
<Result>1</Result>
<Node>
<Version>4</Version>
<Type>Container</Type>
<Children>
<Child>
<Name>edprops</Name>
<Type>Container</Type>
</Child>
<Child>
<Name>state</Name>
<Type>Value</Type>
</Child>
<Child>
<Name>presence0</Name>
<Type>Container</Type>
</Child>
<Child>
<Name>clide</Name>
<Type>Value</Type>
</Child>
</Children>
</Node>
</Answer>
You can see from this example that the children of a container node may have a mixture of node types.
Errors
An attempt to access a non-existent node will result in something like the following:
http://localhost:9999/ScriptHook/Get?Path=/thobs/196772622/edprops/forcefield/valxx
<Answer>
<Result>0</Result>
<ErrorCode>4400001</ErrorCode>
<ErrorDetails>No node exists at path '/thobs/196772622/edprops/forcefield/valxx'</ErrorDetails>
</Answer>
ScriptHook Hierarchy
The root of the ScriptHook hierarchy is the path “/”, which is a container node providing the following main branches:
-
/acc
allows you to make your avatar speak text, or perform an emote. -
/client
gives access to system messages and GUI windows. In addition, you can simulate mouse button clicks and key presses. -
/mainMenu
provides access to the main ThereClient menu system. It is only present when the main menu is on the screen, so cannot be used while in ActionMode. -
/pilotPobs
presents access to different classes of pob owned by the avatar. -
/thobs
contains a sub-tree for the thob associated with each visible dob.
/acc
ScriptHooks
The /acc
ScriptHook sub-tree provides access to Avatar Centric Chat through a single method /acc/addChatText
. You can invoke this with additional arguments to have your avatar “speak” the text. This functionality includes the ability to perform emotes. For example, performing a GET on the following URL makes your avatar jump for joy:
http://localhost:9999/ScriptHook/Invoke?Path=/acc/addChatText&Args=text%3D'''yay'
Note that the nested “=” character in the Args
argument is encoded as %3D
to prevent that part of the URL being parsed incorrectly. Similarly, if you want to put a space character in the text, you should encode it as either a “+” or a “%20”. You can include a newline character (like hitting the carriage return key) by including one encoded as “%0A”.