Original script thread closed for inactivity. I'm re-posting the introduction here, but see the original link for more examples and discussion: <a href="https://app.roll20.net/forum/post/9046603/anybody-wanna-beta-test-a-default-token-spawning-script-with-toys/?pageforid=9046603#post-9046603" rel="nofollow">https://app.roll20.net/forum/post/9046603/anybody-wanna-beta-test-a-default-token-spawning-script-with-toys/?pageforid=9046603#post-9046603</a> Re-posted below: So this started out as a simple script to help automate KeithCurtis' cool trick using rollable table tokens and !token-mod to generate spell effects, illustrated here , but kind of expanded from there. I first looked at King's excellent !Summon script, but it seemed like it did not support setting sides of rollable table tokens or some other features I was looking for, so I thought it would be a fun project. Kind of went down a rabbit hole with options, but it was a fun learning experience. Thought I would share in case others found a use for it or had any suggestions for new or existing features, or just had general feedback like "...but why?". Many thanks to TheAaron, timmaugh, GiGs, and others who helped me through a few technical roadblocks along the way! I'm sure it is a hot mess as I was learning stuff as I went, but it seems to work and was fun so I'm ok with that. Concept Like !Summon, !Spawn can be used for spell effects, monster summoning, cataclysmic terrain changes, or any similar type application. The general idea is to automatically spawn the default token for a given "character" with various options for token qty, location/arrangement, and certain token properties such as size, side (for rollable table tokens), light emission, and "represents" property. In addition, I wanted to be able to automatically call a character "Ability" after the spawn event. This last part has a few caveats, which I will address later in the post. Support my work on Patreon I've been asked by a few folks if they can provide support in appreciation for a script or other help. If you find yourself falling into that group, too, then thank you! If not, no worries - it's not why I do this. I just want everyone to have as much fun as possible playing the games that they love! Disclaimer: Patreon campaigns are not affiliated with Roll20. Contributions are entirely voluntary and Roll20 cannot provide support or refunds for contributions. Example: Click image to see Animated gif of a baddy raising 8 minions/mooks (appearing as random sides of a rollable table token) around each of two targets: Example 2: This example spawns four dancing lights with a rollable table token (GenericSpellAoE) in a burst two squares from the selected character. The token is set to emit dim light (LDL) as per the spell description. The character casting the spell has darkvision with a light multiplier of two, in case anybody is counting squares :) !Spawn {{
--name| GenericSpellAoE
--qty| 4
--placement| burst 2
--offset| 0,0
--force| yes
--size| 1,1
--side| 7
--order | toFront
--light| 10,-5
}} Click for animated gif: YouTube Demo Video by Nick O! Wanted to thank Nick O. for the great demo video highlighting a few of the features of this script. Check it out here ! Note: If you want to use the script for spawning the party on a new page as he details, I'd recommend something along the likes of that described here to avoid inadvertent alterations to your PC's linked bar values (hp, ac, etc.). His video was using a previous version (v0.11), and that particular application of the script revealed some strange behavior that prompted changes in v0.12. Thanks, Nick! Version History --v0.2 fixes bug that prevented non rollable table tokens from spawning correctly --v0.3 provides UDL support for the --light command. See updated command notes for differences in use of this command between LDL & UDL --v0.4 supports floating point (decimal) --size parameters for partial square token sizes --v0.5 added limited support for triggering FX at spawn origin points. See updated command notes. Currently no custom FX or those that require directional input. --v0.6 now compatible with the TheAaron's TokenNameNumber script (v0.5.12 or later). Spawned tokens whose default token has the text %%NUMBERED%% somewhere in the name will have a sequential number appended to their name. --v0.7 added new placement option --placement|cross # , which distributes spawned tokens similar to "burst,", but in a vertical & horizontal reticle arrangement. # is radius (in squares) of the innermost spawned tokens relative to the origin token(s). --v0.8 added ability to override the token bar values. --bar1| <current> / <max> . Max is optional. If command is used, then the corresponding bar "link" will be removed, if present. Values for current & max can be formulas using attributes and/or queries. e.g. --bar1| [[ @{charName|constitution}+10*?{Spell Level?|1} ]] --v0.9 added new command --expand| #,# , which causes the token to spawn first as a point, and then expand to full size based on user configurable number of frames and delay between frames (determining frame rate). --v0.10 bug fix for certain cases where the default token does not have layer information. Now explicitly sets the spawn layer to that of the origin token(s). Side benefit: can now spawn on non-object layers (e.g. GM layer). --v0.11 Corrected error handling for cases when no character sheet is found or when the requested auto-trigger ability is not found. --v0.12 Added the " KeepLink " keyword to the --bar1, --bar2, etc commands to preserve the token-bar-to-character link for bar values when they override those of the default token. --v0.13 Bug fix to ensure default token light settings were being honored. --v0.13a Stealth update that now allows floating point numbers for the --offset parameter. Useful for spawning larger tokens that might otherwise end up a half square off from grid. --v0.14 Corrected Mook behavior and added selected/target deletion and/or animation options. See post for details. --v0.15 Added random placement & delete-after-expand options, and removed the qty limit. See post for details --v0.16 Added --rotation command. Only numeric values or the text "rand", "random" ar allowed --v0.17 Added --layer command. User may now specify the layer in which token(s) will spawn. Default behavior is the same layer as selected token(s) --v0.18 Added --isDrawing command. Also, --size will now accept either X,Y parameter or a single # (will set X=Y=#). --v0.19 Added --tokenName command, allowing the spawned token to have a different name than the default token and/or character name. --v0.20 Added support for non-70px grid scales --v0.21 Fix bug introduced by v0.19 that had broken compatibility with TokenNameNumber --v0.22 Bug fix. When only one value is given for --bar override, the bar max will now also default to the value given --v0.23 Added the --tooltip command --v0.24 Added the --controlledby and --tokenProps commands --v0.25 Added optional text to --targets command Available on One-Click , or Get the code here: <a href="https://github.com/djmoorehead/roll20-api-scripts/blob/master/Spawn%20Default%20Token/SpawnDefaultToken.js" rel="nofollow">https://github.com/djmoorehead/roll20-api-scripts/blob/master/Spawn%20Default%20Token/SpawnDefaultToken.js</a> Instructions Case 1: Selected token is the basis for spawn origin To use, select one or more tokens on the map, and call the script with at minimum the name of the "character" to summon. The following will simply spawn 1 of the default character tokens in the center of each selected token. !Spawn --name|charName Case 2: Target token is the basis for spawn origin Initial token selection is still required (as it is used for some defaults), but you can optionally cause the tokens to spawn at targeted token(s), with a little trickery. Roll20 has a standing bug that if both selected and target tokens are passed to an api script, the selected tokens are not retained. To get around this, after the initial call, the script will generate a chat button to prompt for a number of targets and will call itself again with the now complete set of information. !Spawn --name|charName --targets|2 A complete description of commands is included below. Note: I put < > around each of the parameters for readability. Don't include < > for actual use. ! Spawn {{
-- name | < charName > //(REQUIRED) name of the character whose target we want to spawn
-- targets | < #, optional Text > //Destination override. Instead of using selected token(s) as origin, use target token(s). If commas are to be included in Text, use replacement value %comma%
-- qty | < # > // DEFAULT = 1 . How many tokens to spawn at each origin point.
//supports hardcoded and rollable table inline rolls such as [[ 1d6 ]] and [[ 1t[tableName] ]]
-- offset | < #,# > //X,Y pos or neg shift in position of the spawn origin point(s) relative to the origin token(s), in number of SQUARES
//DEFAULT = 0,0 // (NOTE: a POSITIVE Y offset means LOWER on the map)
--placement| < option > //How to arrange the tokens relative to the origin point (+ offset). Options are:
//' stack ' : (DEFAULT) All tokens will be stacked on top of each other
//' row ' : A horizontal row of tokens
//' column , col ' : A vertical column of tokens
//' surround ' : A clockwise spiral placement around origin token, starting at top (NOTE: any supplied offset will be ignored)
//' grid #' : A square grid with "#" tokens per row. Raster left to right
//' burst #' : An expanding diagonal distribution of tokens starting "#" squares from the 4 origin token corners. Large qty will form an "X" pattern
// 'cross #' = "evenly" distributed vert/horiz cross pattern, starting directly above origin by # squares. Large qty will form a "+" pattern // 'random,rand #' : randomly populates tokens within a (# by #) square grid -- size | < #,# > or < # > // DEFAULT = 1,1 (X,Y) - How many SQUARES wide and tall are the spawned tokens? If only one number is given, X & Y are set to equal size
-- side | < # or rand > // DEFAULT = 1 . Sets the side of a rollable table token.
// # : Sets the side of all spawned tokens to "#"
// 'rand,random' : Each spawned token will be set to a random side
-- order | < option > //The z-order of the token. (NOTE: a recent Roll20 "feature" will always put character tokens with sight above those without, so YMMV.)
// toFront,front,top,above : Spawn token moved to front
// toBack,back,bottom,below : Spawn token moved to back
-- light | < #,# > //Set light radius that all players can see.
// For Legacy Dynamic Lighting (LDL):
//First # is the total radius of the light (light_radius) //Second # is the start of dim light (light_dimradius) (so: 10,5 will be 10 ft of total light, with dim radius starting at 5ft)
// For Updated Dynamic Lighting (UDL):
//First # is the radius of bright light (bright_light_distance)
//Second # is the additional radius of dim light (so: 10,5 will be 10ft of bright light + 5ft of dim light)
-- mook | < yes/true/1/no/false/0 > // DEFAULT = false (any linked bar values are retained)
//If set to true, bar links are removed
-- force | < yes/true/1/no/false/0 > // DEFAULT = false . The origin point is by default relative to the geometric center of the origin token
//Origin tokens of larger than 1x1 may spawn tokens in between squares, which may be strange depending on the specific case
//Set to true in order to force the token to spawn in a full square
-- sheet | < charName2 > // DEFAULT = selected character . The character sheet in which to look for the supplied ability
//useful if the ability exists on a "macro mule", etc.
-- ability | < abilityName > //The ability to trigger after spawning occurs. With caveats as described below
--fx| < type-color > //Trigger FX at each origin point.
//Supported types are: bomb,bubbling,burn,burst,explode,glow,missile,nova,splatter
//Supported colors are: acid,blood,charm,death,fire,frost,holy,magic,slime,smoke,water
--bar1| < currentVal/optionalMax optional "KeepLink"> //overrides the token's bar1 current and max values. Max is optional. Default is to remove bar1_link. If "KeepLink" is appended, the bar1_link will be preserved
--bar2| < currentVal/optionalMax optional "KeepLink"> //overrides the token's bar2 current and max values. Max is optional. Default is to remove bar2_link. If "KeepLink" is appended, the bar2_link will be preserved
--bar3| < currentVal/optionalMax optional "KeepLink"> //overrides the token's bar3 current and max values. Max is optional. Default is to remove bar3_link. If "KeepLink" is appended, the bar3_link will be preserved
-- expand| < #frames, delay , optional yes/true/1 > //Animates the token during spawn. Expands from size = 0 to max size. If third param =true, will delete spawned token after animation completes
//#frames: how many frames the expansion animation will use. Start with something like 20 //#frames: how many frames the expansion animation will use. Start with something like 20
//delay: how many milliseconds between triggering each frame? Start with something like 50. Any less than 30 may appear instant --deleteSource| < yes/true/1/no/false/0 > //DEFAULT = false. Deletes the selected token(s) upon spawn
--deleteTarget| < yes/true/1/no/false/0 > //DEFAULT = false. Deletes the target token(s) upon spawn
--resizeSource| < #,# <optional #frames, #delay> > //DEFAULT = n/a. Animates the selected token(s) during spawn.
//#,#: the new size of the selected token(s). If any dimension is set to 0, it will delete the token after animation
//#frames: DEFAULT = 20. how many frames the animation will use.
//delay: DEFAULT = 50. how many milliseconds between triggering each frame? Anything less than 30 may appear instant
--resizeTarget| < #,# <optional #frames, #delay> > //DEFAULT = n/a. Animates the target token(s) during spawn.
//#,#: the new size of the target token(s). If any dimension is set to 0, it will delete the token after animation
//#frames: DEFAULT = 20. how many frames the animation will use.
//delay: DEFAULT = 50. how many milliseconds between triggering each frame? Anything less than 30 may appear instant --rotation| < #/random/rand > //sets the angle of the spawned token during runtime --layer| < object/token/map/gm > //user may specify the layer in which token(s) will spawn. Default behavior is same layer as selected tokens --isDrawing| < yes/true/1/no/false/0 > //DEFAULT = false. Sets the isdrawing property of spawned token --tokenName| < some name > //optional override for the token name - allows token name to be different than the character name --tooltip| < some text > // adds a tooltip to the spawned token(s) --controlledby| <optional +> <comma-delimited list of playerIDs or displayNames> //adds or replaces the controlledby property of the CHARACTER SHEET defined by the --name command
--tokenProps|<prop1:val1,prop2:val2...> //sets various token properties. Valid properties include:
name,statusmarkers,bar1_value,bar1_max,bar2_value,bar2_max,bar3_value,bar3_max,top,left,
width,height,rotation,layer,aura1_radius,aura1_color,aura2_radius,aura2_color,aura1_square,
aura2_square,tint_color,light_radius,light_dimradius,light_angle,light_losangle,light_multiplier,
light_otherplayers,light_hassight,flipv,fliph,bar1_link,bar2_link,bar3_link,represents,layer,
isdrawing,name,gmnotes,showname,showplayers_name,showplayers_bar1,showplayers_bar2,showplayers_bar3,
showplayers_aura1,showplayers_aura2,playersedit_name,playersedit_bar1,playersedit_bar2,
playersedit_bar3,playersedit_aura1,playersedit_aura2,lastmove,tooltip,show_tooltip,
adv_fow_view_distance,has_bright_light_vision,has_night_vision,night_vision_distance,
emits_bright_light,bright_light_distance,emits_low_light,low_light_distance,has_limit_field_of_vision,
limit_field_of_vision_center,limit_field_of_vision_total,has_limit_field_of_night_vision,
limit_field_of_night_vision_center,limit_field_of_night_vision_total,has_directional_bright_light,
directional_bright_light_center,directional_bright_light_total,has_directional_dim_light,
directional_dim_light_center,directional_dim_light_total,bar_location,compact_bar,
light_sensitivity_multiplier,night_vision_effect,lightColor }} The --placement option is the trickiest one to describe, so here is a reference chart to show how --placement and --offset relate to each other for multiple tokens. Note how the --offset command is ignored for the --placement|surround option. Here is a completely unrealistic example from a game mechanics standpoint, spawning 1d4+1 Dancing Lights or Flaming Spheres in a burst 1 pattern originating three squares below a target token, then triggering the "SpellTemplate" ability on the "Yelric" character sheet. !Spawn supports multi-line commands using the double bracket syntax. Also, will support case insensitive search and allows extra spaces between commands, parameters and delimiting characters ("--", "|", and ","), so the following will still work: !Spawn {{
--naMe | GenericSpellAoE
--targeTs |1
--qty| [[ 1d4 + 1 ]]
--offset | 0 , 3
--placement| buRst 1
-- size|1,1
--side| ?{Spell?|Dancing Lights,7 |Flaming Sphere,2}
--order | toFront
--light| 10,-5
--force|yes
--sheet|YeLriC
--ability|SpellteMplAte
}} Caveats/Known Issues 1) Like with any other scripts that affect images, Roll20 limits api access to only images found in the user's personal art library . Annoying. So, if you have purchased Marketplace content, you will have to go through the arduous process of getting those images into your "My Library". Select token, press Z, right-click, save image locally, then re-upload to Roll20. 2) Also not currently accessible by the api are: Bar position & bar styles . So, no compact bottom overlapping bars for your spawned mooks until Roll20 allows that to happen. 3) The Ability triggered after spawning is currently pretty temperamental. This is irritating because it was one of the main features I was looking for. The following seem to cause problems: a) When the ability contains a query, things break. b) When the ability is whispered, it just gets ignored (?!). I don't fully understand this. I have a cheesy workaround that kinda works but is not yet implemented, as it forces the whisper to the player that made the api call. This probably would be ok for 99% of cases, but I'd like it to be more generic. There is a forum thread here that discusses the issue. c) If the ability calls another ability or macro either directly or via chat buttons, things break. Chat buttons will be created, but will fail when clicked NOTE: If anybody wants to wade through any of these Ability issues, it is found at the very bottom of the processCommands function. Search for the comment " automatic trigger of a supplied ability " to jump directly to that portion of the code. Links to more Examples with animated gifs: Example used in conjunction with another of my scripts (DLDark) to cast a cloudkill that heavily obscures (old thread) Example using spawn "animations" and fx (old thread) Example using bar override values (old thread) Examples using source token resize and/or deletion (current thread) Example use with the scriptcards api script to simulate random placement (current thread) Example with built-in support for random token placement and deleting the spawned token after animation (current thread) Example to change scenes for Theater of the Mind sessions (current thread) Examples for random placement and deleteafterexpand options Example for the 5e Conjure Animals Spell (requires other scripts, see "Option 2" of the link)