-
Notifications
You must be signed in to change notification settings - Fork 7
Statement Types (Quick Reference)
Kurt Jaegers edited this page May 28, 2024
·
10 revisions
The following table summarizes the available ScriptCards statement types:
| Identifier | Statement Type | Tag | Content | Notes |
|---|---|---|---|---|
| --/ | Comment | unused | unused | The --/ sequence is used to add comments to a script. No processing will take place on a --/ line, so the tag and comment can be freely used to add notes to your code. |
| --\ | Console Log | unused | Log Text | Log the content to the API console log. |
| --# | Set ScriptCards Setting | Parameter name | Desired parameter value | Parameters generally control the behavior of large segments of the output card. Things like the Title of the card, the colors of the header and rows, etc. There are also parameters that control how various features of the card behave (like "usehollowdice"). |
| --+ | Direct Output | Free Text - Is output in bold at start of the line. | Output in normal text after Tag | Direct Output statements are what creates row sections on the output card. A script without any direct output sections will end up looking similar to the sample at the start of this wiki (the !script {{ }} script) because all other statement types do not create output lines. |
| --= | Assign Roll Variable | Variable Name | Roll Equation (or text) to assign | Roll/Numeric variables are assigned with this command. The content will be processed as a dice roll, and various properties will be set along with the numeric results. |
| --& | Assign String (or Array Element) Variable | Variable name | Content to store in the string variable. | Roll Variables and String Variables are completely separate entities, and can technically share names, but this would likely lead to confusion and should be avoided. Elements in an array can be assigned with this statement by specifying the array name followed by the index number you wish to assign in parenthesis (ex: Fruits(4)) as the variable name |
| --@ | API Call | API ! Command | API call parameters (replace -- with _) | Other Roll20 API scripts can be called using this command. The Tag is the trigger command for the API script (e.g., !token-mod, or !setattr, etc.) |
| --: | Branch Label | Label Name | Unused (Comments if desired) | Branch labels are the destination for branch and procedure call statement types. The content portion of the statement is unused, though it is recommended to list parameter information here if you are writing a procedure that accepts passed parameters |
| --^ | Branch To (GOTO) | Label name to branch to | Unused (Comments if desired) | An unconditional branch to a label (--:). Execution of the script will jump to the line after the named label. A GOTO branch does not support parameter passing or a return point. |
| --> | Call Procedure (GOSUB) | Label name to call | Procedure parameter list semicolon (;) separated | An unconditional procedure call. Execution will jump to the line after the named label, and a return statement (--<) will return execution to the line after the procedure call. Procedure calls can be nested and called recursively. |
| --< | Return from Sub | Unused | Unused (Comments if desired) | The return statement returns execution to the most recent procedure call line. Note that the vertical bar is required for the statement to be complete. |
| --? | Conditional Statement | Condition to be evaluated | True action | False action |
| --s | Store to Persistent Storage | "settings", "rollvariables", or "stringvariables" | Name of the data set to store (see save/load section below) | This statement type (and the --l statement) still function, but it is recommended to use the storage mechanism in the --~ command instead. |
| --l | Load from Persistent Storage | "settings", "rollvariables", or "stringvariables" | Name of the data set to store (see save/load section below) | This statement type (and the --s statement) still function, but it is recommended to use the storage mechanism in the --~ command instead. |
| --v | Create Visual Effect | "token", "betweentokens", or "point" | Tokens and parameters for generating the effect | Visual effects are played on the page the token is on. "point" effects require Version 1.2.8+ |
| --a | Play Audio Track | Unused | Jukebox track name (case sensitive) | Plays an audio track by name from the Roll20 jukebox. Requires v1.5.2+ |
| --e | Echo to Chat | Name to send chat command as | Chat message to send | Variable substitution takes place on the tag and content. |
| --R | Retrieve Repeating Section Row information | "find", "first", "next", "byindex", "bysectionid", "dump" | Parameters for retrieving row information. See Referencing below | Working with repeating section information on character sheets is possible without tracking row indexes ($0, $1, etc.) by using the --R statements. |
| --~ | Assign a variable to the result of a built-in function | Variable Name | Parameters for function call | ScriptCards includes a number of built-in functions for things like measuring distance, manipulating strings, etc. The type of variable that gets set (Roll or String) is dependent upon the function that is being called. |
| --c | Case Statement | Test Value | Vertical bar separated list of cases, with the match:branchlabel format. | Branch labels can be procedure calls by prefixing them with ">", and can contain parameters. |
| --i | Information Request | User Prompt;Button Caption | InfoType;VariableName;ParameterText | See full documentation below. |
| --d | Data Statement | ! for data definition or StringVar for data read | For definition lines, a semicolon separated list of data elements. Unused to read lines. | Similar to BASIC read/data statements. --d! defines string data elements anywhere in your code. --dvarName reads the next data element into varName. |
| --% | For...Next Loop | Loop Counter for "For", empty for "Next" | For "For", Start;End;Step, empty for Next | See For...Next Loop documentation below. Allows you to create loops that will run a specified number of times with a loop counter. |
| --* | GM Output | Free Text - Is output in bold at start of the line. | Output in normal text after Tag | GM Output statements are whispered to the GM as a separate card after the output of the main card is completed. Their use is identical to the Direct Output statement (--+). If there are no GM Output statements in a card, no GM card will be whispered. |
| --! | Object Modification | : | setting:value | setting:value... |
| --X | Exit Script | none | none | End script processing and exit the script. |