ScriptCards 2.7.8 Now on OneClick The latest version of ScriptCards (2.7.8) has been pushed to OneClick. It is a big one, so here is a summary of the changes since 2.6.6: - Added array fromrollvar which will convert the array items in a roll variable into a standalone array. Syntax: --~|array;fromrollvar;ArrayName;RollVariableName;type where type is "rolled", "kept", or "dropped". NOTE that the roll variable name is just the name of the variable and not a [$rollvar] reference. Added built-in array variable "args" which will be set to the parameters (arguments) passed to a GOSUB command. This means that you can use [@args(0)] in place of [%1%], etc. Note that arrays are zero-based. [@args(length)] and [@args(maxindex)] can be used to retrieve the number of parameters passed. The older [%x%] references still work, but you can use this to call a function with a variable number of parameters, or use a foreach loop for them, etc. Fix sandbox crash error in destroy:graphic trigger and added error handling to destroy:page and destroy:door code as well. If you have a ScriptCards_Triggers character defined when your sandbox starts, ScriptCards will register to observe changes from Token-Mod and run the change:graphic trigger if it exists when tokenmod announces a change. The listen to tokenmod behavior defaults to off to prevent issues with existing code. You can set an attribute on the ScriptCards_Triggers character called 'listen_to_tokenmod' and make its current value 1 to enable this behavior Added --~|array;attributes;ArrayName;charid;(optional 'name' starts with) . Returns an array of IDs for attributes on a character. If the last parameter is specified, only attributes with names starting with that value will be returned. Storing empty hash tables will now remove the attribute from the storage character Added function: --~|array;fromplayerlist;ArrayName . Returns an array of all of the IDs of all of the players (that aren't GMs) in the game Added function: --~|array;fromgmplayerlist;ArrayName . Returns an array of all of the IDs of all of the GM players in the game Added function: --~StringVar|system;playerisgm;playerpageid . Will set the StringVar string variable to 1 if the passed playerid is a GM, otherwise will set it to 0 Added function: --~|array;fromcontrolledcharacters;ArrayName;playerid . Will return an array of all of the characters controlled by the passed player Updated [*O:...:character:...] to accept "isgm" as a psuedo property, which will return 1 if the player object is a GM and 0 if not. Ex: --+GM?|[*O:[&SendingPlayerID]:player:isgm] Added a new function: --~|system;runaction;character_id;abilityname;param1;param2;param3;param4;... This function will look for an ability called "abilityname" (case sensitive) on character "charcter_id" and read the Action property of the ability. It will replace the text [REPL1], [REPL2]... and so forth with the parameters passed in param1, param2, etc. The sequence -_-_ will be replaced in the final macro, allowing you to potentially add lines to anything that uses -- to separate parameters, etc. Note that the calls are issued by the API, so there is no current player, so interactive scripts will not do anything (ie, targets, roll queries, etc.) but if the action you are using takes ids, you can pass them as [REPL] items. Example: Given the SetMacro ability on the "Macro_Mule": !token-mod --ids [REPL1] --set statusmarkers|[REPL2][REPL3] T his will turn on the blue marker: --~|system;runaction;@{Macro_Mule|character_id};SetMarker;@{selected|token_id};+;blue And this will turn it off: --~|system;runaction;@{Macro_Mule|character_id};SetMarker;@{selected|token_id};-;blue In these examples, [REPL1] gets replaced with the selected token id, [REPL2] gets replaced with either + or -, and [REPL3] gets replaced with blue. Obviously these can be variables or other ScriptCards constructs. Note that "runability" is an alias for "runaction" Removed some extraneous logging that might cause slowdowns in some scripts as junk was output to the API Console. Updated parsing code to completely ignore --/ lines by skipping the processing block if the tag stats with / Added optional parameter for Rbysectionid . If you add a ;1 to the end of the call, it will perform a case-insensitive match. Added " !sc-purgestachedscripts " as an alternatively recognized command. This will clear from memory all script that have been "stashed", either by reentrant code or --i commands the only real effect here is to free up memory, as this happens automatically on a sandbox restart. Added " --rsearch ", which has the same syntax as --rfind, except that it will do a case-insentitive partial match. This is converted to a regex, so if you need to find special regex characters (like +), prefix them with a "\". Ex: --rsearch|@{selected|character_id};sword;repeating_attack;atkname Will search for the first repeating_attack with an atkname containing "sword" and set the repeating index to that row. Ex2: --rsearch|@{selected|character_id};\+3;repeating_attack;atkname Will search for "+3" and return the first item containing it. Corrected bug where specifying a default value when setting an attribute resulted in an extra preceeding ":" Added --~|hashtable;getjukeboxtracks;HashTableName . This will create a hash table with the names of every jukebox track as keys and their object ID. It will also create keys with TrackName-playing, TrackName-loop, and TrackName-Volume. Here is a simple jukebox/soundboar !script {{ --#reentrant|jukebox --:SHOW_JUKEBOX| --#hidecard|0 --~|hashtable;getjukeboxtracks;myhash --~|array;fromkeys;keys;myhash --%keys|foreach;keys --?"[&keys]" -ninc "-"|[ --+[&keys]|[r][rbutton]Play::PLAY_AUDIO;[&keys][/rbutton][/r] --]| --%| --+|  --+|[c][rbutton]Refresh Jukebox::SHOWJUKEBOX[/rbutton][/c] --X| --:PLAY_AUDIO| --#hidecard|1 --a|[&reentryval] -X| }} Rewrote distance functions to consolidate code, use better practices When using --~|turnorder;addcustom , you can now specify and additional parameter to determine where in the turn order the entry gets inserted. You can leave the custom counter and formula empty (;;;) if you don't want to specify them, but the semicolons must be there. The available placement options are "top", "bottom", "before:tokenid", "after:tokenid" Ex: --~|turnorder;addcustom;My Fancy Custom Turn;99;-1;after:@{selected|token_id} Major refactoring of the ScriptCards code to improve maintainability and be more friendly to the sandbox. Added the --z command to edit z-order information for objects. --z:objecttype:objectid|operation currently supports tofront and toback for graphics. Will support additional items/options when the March 2024 API update is released. Added --#storagecharid setting to allow you to specify a character ID for future --s and --l statements (in the currently running script) Added --#gmoutputtarget setting which defaults to "gm". If you set this to "self" the output of --* lines will be whispered to the player executing the script. You can also set this to any other valid whisper target. Added --#functionbenchmarking which defaults to 0. Set to 1 to turn on some basic statistics about calls to functions (with -->). After your script finishes running the number of calls to each called function will be reported in the API console log as well as the number of milliseconds the script took to run. Added --~|array;fromkeys;ArrayName;HashTableName which will create an array with all of the keys in a given hashtable Added --~|hashtable;fromobject;HashTableName;objecttype;objectid Ex: --~|hashtable;fromobject;myhash;character;@{selected|character_id}| this function will look up the given object and parse out all attributes (except bio, notes, and gmnotes) into a hashtable with key/value pairs equal to the attribute names and values. Example: !script {{ --~|hashtable;fromobject;myhash;graphic;@{selected|token_id} --~|array;fromkeys;keys;myhash --%keys|foreach;keys --+[&keys]|[:myhash("[&keys]")] --%| }} Added --~|hashtable;getplayerspecificpages;HashTableName which retuns a hash with the contents of the Campaign's playerspecificpages object, which will have player IDs as keys and page IDs as values for those entries. Added --~|hashtable;setplayerspecificpages;HashTableName which will set the Campaign's playerspecificpages object. The source hash table should contain player IDs as keys and page IDs as values for them. Leave off the hash table name (but include the semicolon (;)) clear the value and return all players to the ribbon page. New Pre-Set String Variable: [&SC_VERSION_NUMERIC] , which will contain the version number in the format 0X0Y0Zr, where X is the major version, Y is the minor version, Z is the update number, and r represents the occasional "a", "b", etc. versions. All components are numeric, so v2.7.0 will be represented as "207000" (2=2, 07=7, 00=0, and 0=no fix update), while a theoretical 2.7.0a would be "207001". This can be used to require a specific minimum version of ScriptCards or to change the behavior of the script depending on the version. For example, the following line: --?"[&SC_VERSION_NUMERIC]" -eq "" -or "[&SC_VERSION_NUMERIC]" -lt 207000|REPORT_BAD_SC_VERSION would check for that minimum version number.