ScriptCards 2.1.7c is now Live on OneClick The latest version of ScriptCards is now live on OneClick.
This version mostly focuses on bringing some convenience features to the
language. Here is the full list of changes since 2.0.2k: -
Additional sandbox protection code for some rare
crash cases -
New options for conditional and case statements: o
You can now specify “<” as the result of a
conditional branch or case result to return immediately from a subroutine call.
For example, “--?[$Roll] -eq 1|<” will return out of the function if the
value of $Roll is 1. o
You can now specify “+” as the result of a
conditional branch or case result to create a line of output conditionally. The
bolded portion of the output line comes first, followed by a semicolon,
followed by the non-bolded content. For example, “--?[$Roll.Base] -eq 1|+Fumble;Something
has gone terribly wrong!” will only output the “Fumble…” text if the die roll
of $Roll was a 1. o
You can now specify “*” as the result of a
conditional branch or case result to create a line of GM-only output
conditionally. The bolded portion of the output line comes first, followed by a
semicolon, followed by the non-bolded content. For example, ‘--?”[*T:resistance]”
-inc “fire”|*Resistant;This creature is resistant to fire attacks’ will only
output the “Resistant…” text if the resistance attribute contains fire, and the
message will only be displayed to the GM. -
Updates to array functions o
The array;stringify function now accepts and
optional additional parameter that, if specified, will be used to separate the joined
array objects instead of the default semicolon. (Ex.
--~Result|array;stringify;MyArray;,) o
The array;sort and array;numericalsort functions
now accept an optional additional parameter. If set to “descending” (or really
just the first for letters – desc) the sort order will be reversed: (Ex.
--~|array;numericsort;MyArray;Descending) -
Object handling has been improved o
Arrays of object IDs for Roll20 objects can now
be returned with the array;objects function. This function has the format:
--~|array;object:OBJECTTYPE;ArrayName;Filter
Where OBJECTTYPE is one of campaign, player, page, path, text, graphic,
character, attribute, ability, handout, macro, rollabletable, tableitem, deck, card,
hand, jukeboxtrack, custfx. The Filter parameter will return only objects whose
filter field starts with the specified text (non-case sensitive). For any
object with a name property, the filter field is “name”. For other objects the
filter field is _displayname for players, title for jukeboxtracks, stroke
(color) for paths, text for text and not supported for campaign, card, and hand
objects.
Ex: --~|array;objects:handout;MyArray;magic item
Returns an array of object IDs for all Handouts with a name starting with “magic
item”. o
Object modification statements (--!) now support
the ability to modify any type of object by specifying the object type and
object id in the tag portion of the statement. Note that very little checking
is done on this (if the property you are setting is imgsrc, the image source
will be reformatted per Roll20
requirements).
Ex: --!graphic:@{selected|token_id}|bar1_value:256
Will set the "bar1_vlaue" property of the selected graphic object to
256. As with variable referencing, you are likely better off using the specific
object type commands (ie, --!t: and --!a:, etc.) when they are available. Note
that setting Bio, Notes, and GMNotes will actually make the setting, but it
isn't immediate and will not necessarily be available if read back within the
same script. It will also throw a console message about needing to pass a
callback. o
The variable reference notation
[*O:objectId:objecttype:property] can be used to retrieve any property from any
type of object (with the standard limitations on bio, notes, etc.) The object
types are campaign, player, page, path, text, graphic, character, attribute,
ability, handout, macro, rollabletable, tableitem, deck, card, hand,
jukeboxtrack, custfx. Note that you are likely better off using the
type-specific referencing types when available (like [*C:] for campaign, etc.)
Note that retrieving the "action" property of a macros and abilities
is not supported, as this will often lead to a sandbox crash as ScriptCards
tries to parse any potential variables in the macro text. -
The built-in turnorder function now supports
sorting the turn order: --~turnorder|sort will sort numerically in descending
order. adding and optional third parameter with a value of either "a"
(for ascending) or "u" (for up) will sort numerically in ascending
order. -
Retrieve Repeating Section information into
Arrays: o
array;fromrepeatingsection;ArrayName;character_id;repeating_section_name;repeating_field_name
will return an array by looking up all of the repeating section entries on
Character_ID for the "repeating_section_name" repeating list and
return an array consisting of all of the values of repeating_field_name for
that section.
Ex: ~|array;fromrepeatingsection;AttackNames;@{selected|character_id};repeating_attack;atkname o
array;fullrepeatingsection;ArrayName;character_id;repeating_section_name;field1:field2:field3;separation_sequence
will return an array the same as fromrepeatingsection except that multiple
fields can be added to the array entries. The returned values will be separated
in the array entry by separation_sequence. Note that the field list is colon
(:) separated.
Ex: --~| array;fullrepeatingsection;MyArray;@{selected|character_id};repeating_attack;atkname:dmgbase:dmgtype;: -
String Variable Referencing now has an extended
syntax that allows you to return substrings, modified versions of strings, or information
about the string. This is done by including the information you want in
parentheses after the variable name inside the [&..] block:
Examples:
[&MyString] = "The quick Brown Fox jumps over the Lazy Dog"
[&MyString(length)] = 43
[&MyString(tolowercase)] = "the quick brown fox jumps over the lazy
dog"
[&MyString(touppercase)] = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
[&MyString(totitlecase)] = "The Quick Brown Fox Jumps Over The Lazy
Dog"
[&MyString(replace,quick,fast)] = "The fast Brown Fox jumps over the
Lazy Dog"
[&MyString(replaceall,o,i)] = "The fast Briwn Fix jumps iver the Lazy
Dig"
[&MyString(contains,Dog)] = 1 <-- Case sensitive contains
[&MyString(contains,dog)] = 0 <-- Case sensitive contains
[&MyString(icontains,dog)] = 1 <-- Non-Case Sensitive contains
[&MyString(indexof,Jumps)] = -1 <-- Case sensitive indexof - indexof
returns -1 if not found
[&MyString(iindexof,jumps)] = 20 <-- Non-case sensitive indexof. First
location where the sequence occurs
[&MyString(lastindexof,o)] = 41 <-- The character position (0-based) of
the last time the sequence occurs
[&MyString(4)] = "Quick Brown Fox Jumps Over the Lazy Dog" <--
Starting at char #4, rest of string
[&MyString(4,5)] = "Quick" <-- 5 characters beginning at
character 4
[&MyString(-3)] = "Dog" <-- The last 3 characters of the
string
[&MyString(-8,4)] = "Lazy" <-- Starting 8 characters from the
end of the string, 4 characters
-
Bug Fixes o
When using --#whisper with a non-blank value,
the output of the emote section was being skipped. It is now shown as intended. o
When using the & branch modifier of a
conditional to set a string to an empty string, the assignment was failing,
leaving the old value in the string. o
Using --!t to set token values to blank is now possible
o
Using --!t to set barX_link values is now
supported