The scripting language (ScriptScript) and RPC server use a common command format and codebase (the ScriptScriptInterpreter class).
The command field is either a "system command", a method call on a TwigObject, or an assignment statement to mutate an object field or property. The syntax of the commands is then one of:
command args ....
objectname: methodname args ...
objectname: propertyname =
value
Whitespace between elements (objectnames, methodnames, args, etc.) can consist of any number of spaces. Newlines may not be embedded, as these are used to denote the end of the command. However, embedded newlines in string constants can be represented using \n. Arguments and property values have the following syntax:
Type | Syntax |
---|---|
Float | Traditional decimal format, e.g. 1.2. |
String | Traditional double-quoted syntax, e.g. "this is a string". Quotes and backslashes may be escaped using \. Newlines should be written \n rather than as actual embedded newline characters. |
Boolean | Either the constant names: true or false |
Object or Type | Object name, without quotes (object names should therefore not have embedded spaces). Only objects of the classes Type or TwigObject can be referred to this way. |
Vector3 | (X Y Z), without commas between coordinates, e.g. (1 2 3). |
These are commands implemented within the scripting language interpreter, and so work both within standalone scripts and within the server.
Command | Description |
---|---|
new Type args ... | Creates a new object |
exit | Terminates the Twig process |
pause seconds | Pauses the script interpreter for the specified number of seconds. Not terribly useful for the server. |
ls | Prints the names of all TwigObjects |
Command | Description |
teleportto position | Moves object to specified position, keeping orientation and other pose attributes constant |
Command | Description |
drop object | Releases grasp on object |
fight/stopfight character | Character attempts to attack character. Currently implemented by making character very negatively valenced. Stopfight makes the object neutrally valanced. |
follow target distance | Non-blocking. Attempts to follow target at distance distance. If target is null, following is canceled. |
gesture arm name | Plays gesture file name.xml through arm (specified by string "left", "right", or "both"). |
goto target | Character moves to specified object |
goto target distance | Character moves to within distance meters of target. |
goto target distance direction | Character approaches target from direction to within distance meters. |
hold object | Grasps object in free hand and holds it loosely at the character's side |
hold object grasp | Grasps object in free hand using specified grasp and holds it loosely at the character's side. Grasp, a string, may be any of "LeftHanded", "RightHanded", "DominantHand","NonDominantHand", "AnyHand", "TwoHanded", or "Any". |
holdforuse object | Grasps object in free hand and positions it for use |
holdforuse object grasp | Grasps object in free hand using specified grasp and holds it for use. Grasp, a string, may be any of "LeftHanded", "RightHanded", "DominantHand","NonDominantHand", "AnyHand", "TwoHanded", or "Any". |
lookat object | Forces character to gaze at object. If object is null, then the character returns to automatic scanning of the environment. |
poseat position facingdirection | Moves character to specified location and sets them to face the specified direction |
say string | Generates dialogballoon for string without waiting for current dialog to complete. Does not block. |
say string addressee | Blocking. Character turns to face addressee and says string. Character waits for any current dialog to complete. |
say string addressee interrupt? reactiontime | Blocking. Character turns to face addressee and says string, If interrupt? is false, then waits for current dialog to complete and pauses for reactiontime seconds before turning and speaking. |
siton object | Character sits on object. |
By default, the title screen object is named "titles".
Command | Description |
fadetoblack seconds | Screen fades to black/titles over seconds. |
fadefromblack seconds | Titles fade away over seconds, revealing stage. |
By default, the server object is named "server".
Command | Description |
report fieldName | Prints the value of fieldName for all objects |
report fieldName includeStatic | Same. If includeStatic is false, objects tagged as static (e.g. trees) will not be listed |
report fieldName includeStatic interval | Same, but generate repeated reports every interval seconds. |