Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Spawn Default Token Thread 2

1637674858

Edited 1637677242
David M.
Pro
API Scripter
That's great Andrea, and thanks Colin! I had tried using a &select construction but must have had some malformed syntax.  Andrea, you could try replacing the @{selected...} with an @{target...}. If you are targeting multiple targets, you'd probably need to build the command string dynamically in scriptcards first. EDIT - This seems to work for me. I moved the Spawn line to after the MissileLoop and only called it once with this line --@forselected+|Spawn _name|Surtur _offset|0,-1 _qty|1 {^&select [&SpawnTargets]} ...and populated the SpawnTargets variable in your FireMissile subroutine with this line --&SpawnTargets|+ [&ThisTarget] Resulting scriptcard: !script {{ --/|Script Name : 5E Magic Missile --/|Version : 2.0 --/|Requires SC : 1.4.0+, alterbars or token-mod to apply damage (Optional) --/|Author : Kurt Jaegers --/|Description : Handles the D&D 5E spell Magic Missile, with the ability to select a dynamic --/| number of targets. --/| --/| You can optionally have damage applied to impacted tokens. The script defaults to using --/| TokenMod to update Bar 3. These can be changed by altering the settings below. --/| If you use one die roll for Magic Missile, update the damageMode variable below. --/|Set this to either "token-mod", "alterbars", or anything else to not apply damage --&damageApplyScript|token-mod --/|Set this to the bar number you use to track hit points --&hitPointsBar|1 --/|If damageMode is 1, a separate die will be rolled for each missile. Set this variable to 0 to, --/|only have a single damage die roll applied to each missile. --&damageMode|1 --/|Magic Missile by the book does Force damage. --&damageType|elettrico --/|===================== There are no customization options below this line ===================== --#title|Meduse --#sourceToken|@{selected|token_id} -->GetAndCheckAp --=SlotLevel|40 --=SkillLevel|[*S:ms_4_lv] --=MissileCount|[$SkillLevel] + 1 --=OneMissileDamage|[$SkillDmg] -->BuildAndAskTargets|[$MissileCount.Total] --=DisplayCount|1 --=MissileDamage|0 --#leftsub|Ap [$SlotLevel] --#rightsub|Ranged Attack --#emoteText|@{selected|character_name} usa [$SlotLevel.Total] AP per lanciare [$MissileCount.Total] meduse elettrificate! --:GetAndCheckAp| --=ApCost|30 --=ApDisp|[*S:Ap] --?[$ApCost.Total] -gt [$ApDisp.Total]|NoSlotsLeft --<| --/|Determine damage subroutine. Start by assuming we aren't going to apply damage --&damageRoutine|DontApplyDamage --?[&damageApplyScript] -eq "token-mod"|&damageRoutine;ApplyDamageTokenmod --?[&damageApplyScript] -eq "alterbars"|&damageRoutine;ApplyDamageAlterbars --:MissileLoop| -->FireMissile|[$DisplayCount.Total] --=DisplayCount|[$DisplayCount] + 1 --?[$DisplayCount] -le [$MissileCount]|MissileLoop --@forselected+|Spawn _name|Surtur _offset|0,-1 _qty|1 {^&select [&SpawnTargets]} -->UsaAp| --#rightsub| Paralizza + Veleno --X| --:FireMissile| --&ThisTarget|[&target[%1%]] --&SpawnTargets|+ [&ThisTarget], --=SkillAtk|( 1d4 + 1 + [*S:totale_intelligenza] ) * 10 --=EnemyDef|( 10 + { 0 , [*[&ThisTarget]:t-bar3_max] } kh1) --=SkillDmg|( [$SkillAtk] / [$EnemyDef] ) {FLOOR} --?[&damageMode] -eq 1|=ThisMissile;[$SkillDmg]|=ThisMissile;[$OneMissileDamage] --=MissileDamage|[$MissileDamage] + [$ThisMissile] --+Medusa|[$DisplayCount.Total]: [$ThisMissile] danni base. -->PlayEffects|@{selected|token_id};[&ThisTarget];none;bomb-holy;none;none --=ResultantDamage|[$ThisMissile.Raw] --?"[*[&ThisTarget]:npc_immunities]" -inc "[&damageType]"|Immune --?"[*[&ThisTarget]:npc_resistances]" -inc "[&damageType]"|Resistant --?"[*[&ThisTarget]:npc_vulnerabilities]" -inc "[&damageType]"|Vulnerable --^DoneResist| --:Immune| --=ResultantDamage|0 --+La Medusa|[$DisplayCount.Total] colpisce con i suoi tentacoli [*[&ThisTarget]:t-name], ma questo sembra ignorarla! --^DoneResist| --:Resistant| --=ResultantDamage|[$ThisMissile] \ 2 --+Medusa|[$DisplayCount.Total] colpisce [*[&ThisTarget]:t-name] per [$ResultantDamage] danni [b]elettrici[/b] --^DoneResist| --:Vulnerable| --=ResultantDamage|[$ThisMissile] * 2 --+Medusa|[$DisplayCount.Total] colpisce [*[&ThisTarget]:t-name] per [$ResultantDamage] danni [b]elettrici[/b] --^DoneResist| --:DoneResist| -->[&damageRoutine]|[&ThisTarget];[&hitPointsBar];[$ResultantDamage.Raw] --<| --:BuildAndAskTargets| --&TargetString| --=targetCount|1 --:TargetLoop| --&TargetString|+t;target[$targetCount.Raw];Missile [$targetCount.Raw] Target --=targetCount|[$targetCount.Raw] + 1 --?[$targetCount] -le [%1%]|>AddSeparator --?[$targetCount] -le [%1%]|TargetLoop --iPlease click the button below to select magic missile targets. The same target can be selected multiple times;Select [%1%] Targets|[&TargetString] --/| --<| --:AddSeparator| --&TargetString|+|| --<| --:NoSlotsLeft| --+|[*S:character_name] non ha abbastanza AP. [$ApDisp.Total] AP disponibili. --X| --/|===================== Subroutines ===================== --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set statusmarkers|Paralizzato|Poisoned bar[%2%]_value|-[%3%] --<| --/|Just a dummy routine that doesn't do anything, but it is easier to do it this way than adding logic to see if we are --/|skipping applying damage in the main routine. --:DontApplyDamage| --<| --:UsaAp| --=ApDisp|[$ApDisp] - [$ApCost] --@modattr|_charid [*S:character_id] _Ap|-[$ApCost] --<| --:PlayEffects|Parameters are : sourcetoken; targettoken; source effect; target effect; line effect; sound effect --vtoken|[%1%] [%3%] --vtoken|[%2%] [%4%] --vbetweentokens|[%1%] [%2%] [%5%] --@roll20AM|_audio,play,nomenu|[%6%] --<| }}
Welcome! I think I understand what you want to do, in principle, but I need more detail. What is the "target location?" I.e., how can we identify it in your script? andrea d. said: IT WORKS!!!!! GENIUS!!! thank you so much!!! now i have to ask, do you know if i can also find a way to summon those two tokens to the target location? or is asking too much? i mean i can drag the tokens but it would be cool to be able to summon them there! thank you again!! Colin C. said: I think you can do something like  --@forselected+|Spawn _name|Surtur _offset|0,-1 _qty|1 {^&select @{selected|token_id}} What should happen is: @{selected|token_id} gets parsed out through the Roll20 chat server ScriptCards runs until you get to the reentry button ScriptCards runs again, stripping out the ^  character in the {^&select structure, which then processes to virtually select the same original selected token ... PROFIT!
1637768612
timmaugh
Pro
API Scripter
Thanks to Colin and David for getting to that solution of how to use SelectManager while I was busy the past few days! *sniff* Seeing other people using your script for solutions is... *sniff-sniff* ... oh, they grow up so fast! =D Colin had the order exactly right (including Profit!), and that order is what lets David's solution (above) work, too. Basically, ScriptCards processes the [&SpawnTargets] structure before the outbound command line ( forselected ) is ever sent. So while metascripts usually run sooner than normal scripts, ScriptCards' ability to re-enter and separately to dispatch a new message gives ScriptCards time to process constructions and then establish a new "message stack" where the metascript constructions (like {&select...} ) can be detected and run at meta-speed.
YES!!!!! HERO!!! this is perfect and exactly what i was looking for! thank you so much to you too Colin! you helped me a lot! can't thank the both of you enough! i'd buy yu a beer if i could! cheers! David M. said: That's great Andrea, and thanks Colin! I had tried using a &select construction but must have had some malformed syntax.  Andrea, you could try replacing the @{selected...} with an @{target...}. If you are targeting multiple targets, you'd probably need to build the command string dynamically in scriptcards first. EDIT - This seems to work for me. I moved the Spawn line to after the MissileLoop and only called it once with this line --@forselected+|Spawn _name|Surtur _offset|0,-1 _qty|1 {^&select [&SpawnTargets]} ...and populated the SpawnTargets variable in your FireMissile subroutine with this line --&SpawnTargets|+ [&ThisTarget] Resulting scriptcard: !script {{ --/|Script Name : 5E Magic Missile --/|Version : 2.0 --/|Requires SC : 1.4.0+, alterbars or token-mod to apply damage (Optional) --/|Author : Kurt Jaegers --/|Description : Handles the D&D 5E spell Magic Missile, with the ability to select a dynamic --/| number of targets. --/| --/| You can optionally have damage applied to impacted tokens. The script defaults to using --/| TokenMod to update Bar 3. These can be changed by altering the settings below. --/| If you use one die roll for Magic Missile, update the damageMode variable below. --/|Set this to either "token-mod", "alterbars", or anything else to not apply damage --&damageApplyScript|token-mod --/|Set this to the bar number you use to track hit points --&hitPointsBar|1 --/|If damageMode is 1, a separate die will be rolled for each missile. Set this variable to 0 to, --/|only have a single damage die roll applied to each missile. --&damageMode|1 --/|Magic Missile by the book does Force damage. --&damageType|elettrico --/|===================== There are no customization options below this line ===================== --#title|Meduse --#sourceToken|@{selected|token_id} -->GetAndCheckAp --=SlotLevel|40 --=SkillLevel|[*S:ms_4_lv] --=MissileCount|[$SkillLevel] + 1 --=OneMissileDamage|[$SkillDmg] -->BuildAndAskTargets|[$MissileCount.Total] --=DisplayCount|1 --=MissileDamage|0 --#leftsub|Ap [$SlotLevel] --#rightsub|Ranged Attack --#emoteText|@{selected|character_name} usa [$SlotLevel.Total] AP per lanciare [$MissileCount.Total] meduse elettrificate! --:GetAndCheckAp| --=ApCost|30 --=ApDisp|[*S:Ap] --?[$ApCost.Total] -gt [$ApDisp.Total]|NoSlotsLeft --<| --/|Determine damage subroutine. Start by assuming we aren't going to apply damage --&damageRoutine|DontApplyDamage --?[&damageApplyScript] -eq "token-mod"|&damageRoutine;ApplyDamageTokenmod --?[&damageApplyScript] -eq "alterbars"|&damageRoutine;ApplyDamageAlterbars --:MissileLoop| -->FireMissile|[$DisplayCount.Total] --=DisplayCount|[$DisplayCount] + 1 --?[$DisplayCount] -le [$MissileCount]|MissileLoop --@forselected+|Spawn _name|Surtur _offset|0,-1 _qty|1 {^&select [&SpawnTargets]} -->UsaAp| --#rightsub| Paralizza + Veleno --X| --:FireMissile| --&ThisTarget|[&target[%1%]] --&SpawnTargets|+ [&ThisTarget], --=SkillAtk|( 1d4 + 1 + [*S:totale_intelligenza] ) * 10 --=EnemyDef|( 10 + { 0 , [*[&ThisTarget]:t-bar3_max] } kh1) --=SkillDmg|( [$SkillAtk] / [$EnemyDef] ) {FLOOR} --?[&damageMode] -eq 1|=ThisMissile;[$SkillDmg]|=ThisMissile;[$OneMissileDamage] --=MissileDamage|[$MissileDamage] + [$ThisMissile] --+Medusa|[$DisplayCount.Total]: [$ThisMissile] danni base. -->PlayEffects|@{selected|token_id};[&ThisTarget];none;bomb-holy;none;none --=ResultantDamage|[$ThisMissile.Raw] --?"[*[&ThisTarget]:npc_immunities]" -inc "[&damageType]"|Immune --?"[*[&ThisTarget]:npc_resistances]" -inc "[&damageType]"|Resistant --?"[*[&ThisTarget]:npc_vulnerabilities]" -inc "[&damageType]"|Vulnerable --^DoneResist| --:Immune| --=ResultantDamage|0 --+La Medusa|[$DisplayCount.Total] colpisce con i suoi tentacoli [*[&ThisTarget]:t-name], ma questo sembra ignorarla! --^DoneResist| --:Resistant| --=ResultantDamage|[$ThisMissile] \ 2 --+Medusa|[$DisplayCount.Total] colpisce [*[&ThisTarget]:t-name] per [$ResultantDamage] danni [b]elettrici[/b] --^DoneResist| --:Vulnerable| --=ResultantDamage|[$ThisMissile] * 2 --+Medusa|[$DisplayCount.Total] colpisce [*[&ThisTarget]:t-name] per [$ResultantDamage] danni [b]elettrici[/b] --^DoneResist| --:DoneResist| -->[&damageRoutine]|[&ThisTarget];[&hitPointsBar];[$ResultantDamage.Raw] --<| --:BuildAndAskTargets| --&TargetString| --=targetCount|1 --:TargetLoop| --&TargetString|+t;target[$targetCount.Raw];Missile [$targetCount.Raw] Target --=targetCount|[$targetCount.Raw] + 1 --?[$targetCount] -le [%1%]|>AddSeparator --?[$targetCount] -le [%1%]|TargetLoop --iPlease click the button below to select magic missile targets. The same target can be selected multiple times;Select [%1%] Targets|[&TargetString] --/| --<| --:AddSeparator| --&TargetString|+|| --<| --:NoSlotsLeft| --+|[*S:character_name] non ha abbastanza AP. [$ApDisp.Total] AP disponibili. --X| --/|===================== Subroutines ===================== --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set statusmarkers|Paralizzato|Poisoned bar[%2%]_value|-[%3%] --<| --/|Just a dummy routine that doesn't do anything, but it is easier to do it this way than adding logic to see if we are --/|skipping applying damage in the main routine. --:DontApplyDamage| --<| --:UsaAp| --=ApDisp|[$ApDisp] - [$ApCost] --@modattr|_charid [*S:character_id] _Ap|-[$ApCost] --<| --:PlayEffects|Parameters are : sourcetoken; targettoken; source effect; target effect; line effect; sound effect --vtoken|[%1%] [%3%] --vtoken|[%2%] [%4%] --vbetweentokens|[%1%] [%2%] [%5%] --@roll20AM|_audio,play,nomenu|[%6%] --<| }}
1637790119
David M.
Pro
API Scripter
Version Update: v0.23 (added tooltip subcommand) -  Development gist Thanks to tinythomas for the suggestion! I finally got around to it ;) Added a simple subcommand to set a tooltip for the spawned token. If multiple tokens are spawned, they will all get the same tooltip. Syntax: --tooltip|text Example: !Spawn {{   --name|imp   --offset|1,0   --tooltip|I'm a monster, rawr! }}
Hi David, just tested it, works like a charm - thanks a lot! :-) Regards Thomas
1638383185

Edited 1638383297
Please accept my apologies for not reading all the replies. If this has already been asked.  I just want to say this API is pure magic. And when I finally figure out Patreon I will be making more contributions.  However can you add a sound effect to Spawn?  I have tried with !roll20AM.......but it doesn't seem to like it.  :-/ No worries if not.  EDIT: Think I have just spotted the solution............
1638388088
David M.
Pro
API Scripter
Glad you like it, Garry! I don't use roll20AM, but I think you should be able to just tack on a line to the beginning or end of your macro, something like this? !roll20AM ...args !Spawn {{     ...args }} If you came up with a different solution, share it here in case others are looking for the same thing :)
Sorry, yeah, what you have suggested is perfect David M. I was putting the roll20AM command within the {{}} of the spawn command. Rather than outside it.  Just tested and works like a dream. :-) Thank you.  David M. said: Glad you like it, Garry! I don't use roll20AM, but I think you should be able to just tack on a line to the beginning or end of your macro, something like this? !roll20AM ...args !Spawn {{     ...args }} If you came up with a different solution, share it here in case others are looking for the same thing :)
I have another very bizarre occurrence going on and I have scoured lightly this thread and not sure I can see (pardon the pun) the solution.  It is regarding spawning a party of tokens on to the map using UDL. Four tokens get spawned, three of the tokens have dark vision 60ft and one has bright light 20ft then dim light 20ft.  When the tokens appear, the dark vision folk can only see darkness for 20ft emanating from the light emitting token then their dark vision as normal beyond that.  The light emitting token player can only see darkness.  If I go in to each token and quickly switch dynamic lighting off then on again, they can see normally again.  I have tried the light emitting token with and without --light|20,20 and same results either way.   Also the dim light is resetting to 0ft. :-( However I have seen the potential solution to this I think just not sure how to implement it. 
1638663337
David M.
Pro
API Scripter
Unfortunately,  changing UDL settings with the api is currently bugged. It is a Roll20 issue that the devs are aware of, but we've been waiting for a fix for months. FWIW, LDL and api scripts work together as expected.
David M. said: Unfortunately,  changing UDL settings with the api is currently bugged. It is a Roll20 issue that the devs are aware of, but we've been waiting for a fix for months. FWIW, LDL and api scripts work together as expected. Ah OK, fair enough. Thank you for the reply David, Spawn is still amazing! It is only a minor glitch. :-) 
1639076642
David M.
Pro
API Scripter
@Garry and anyone else using Spawn with UDL: It looks like the Dec 7 Roll20 update addressed the UDL-settings-via-api problems. I didn't some preliminary testing and it looks like the UDL settings are being honored immediately upon spawning. Give it a shot!
1639234587

Edited 1639235198
David M. said: @Garry and anyone else using Spawn with UDL: It looks like the Dec 7 Roll20 update addressed the UDL-settings-via-api problems. I didn't some preliminary testing and it looks like the UDL settings are being honored immediately upon spawning. Give it a shot! Hi David, just tried spawning party and the problem still exists :-( when the tokens appear the immediate 20ft radius is black, emanating from the person with bright light, until I go in to each token and turn UDL off then on again, then they can see again. The person with 20ft bright, 20ft dim, the 20ft dim part reverts to 0ft.  I turned off all light emanating from token with no dark vision. Spawned the party, no problem, gave non dark vision token light and then it emanates darkness for the dark vision tokens. Again if I go in to each dark vision token turn UDL off then on, they can all see normally again. 
1639252065
David M.
Pro
API Scripter
Ah, so following Garry's lead I did some more testing and it seems that the Dec 7 Roll20 patch was only partially successful. Setting UDL light emission  from the api is now instantaneous (including directional light), but UDL vision still appears to be delayed until the token settings are opened and saved (without making changes). Sigh. Well, at least it's some progress.
David M. said: Ah, so following Garry's lead I did some more testing and it seems that the Dec 7 Roll20 patch was only partially successful. Setting UDL light emission  from the api is now instantaneous (including directional light), but UDL vision still appears to be delayed until the token settings are opened and saved (without making changes). Sigh. Well, at least it's some progress. Thank you David, we will get there......
1639342621
timmaugh
Pro
API Scripter
Garry Miller said: David M. said: Sigh. Well, at least it's some progress. Thank you David, we will get there......
1639343069
David M.
Pro
API Scripter
Haha, feels like that sometimes, Tim!
@Timmaugh very good. :-) 
1641772019
David M.
Pro
API Scripter
Placeholder post. I should be getting an update out in the next couple days and wanted to keep the thread from being archived.
1641993004

Edited 1641993023
David M.
Pro
API Scripter
Version Update: v0.24 (controlledby and tokenProps subcommands) -  Development gist (1) Added the --controlledby subcommand to add or replace the controlledby property of the CHARACTER SHEET the spawned token represents. Valid tokenIDs or displayNames can be used, plus the "all" keyword. Syntax: --controlledby|<optional "+"> <comma-delimited list of playerIDs, displayNames, or "all"> Examples: --controlledby|all                                //replaces existing control with "All players" --controlledby|-LUl7IlELzYyjUrLTmdz               //replaces existing control with the playerID given --controlledby|David M., -LUl7IlELzYyjUrLTmdz     //replaces existing control with the two players given (can mix/match playerID & displayNames) --controlledby|+David M., Bob                    //Appends "David M." and "Bob" to the existing list of controlling players (2) Added the --tokenProps subcommand.  Sort of a catch-all. Sets various token properties via a comma-delimited list of property:value  pairs. Previous discrete token property commands are still valid (and recommended for readability and in some cases more functionality, i.e. --bar1/2/3). If a token property is set via previous discrete command and via --tokenProps, the --tokenProps values will be used due to the order of operations within the script. Note:  for text properties, commas will mess up the parsing. So, if you to include a comma in say, the "tooltip" field, use the special code %comma% Syntax: --tokenProps|<prop1:val1,prop2:val2...> Examples: --tokenProps|flipv:true --tokenProps|tooltip:My name is Bob%comma% but you can call me Fred, aura1_radius:5  --tokenProps|statusmarkers:dead%comma%red Valid token properties include the following. 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
Wow that's cool ! Will these comands be accessible from other of your scripts ? I'm actually thinking of SmartAoE for example, so we could add an aura on your Conditionfail or pass command. Thanks for your work that gives so much flexibility to our games.
1642031227
MAMS Gaming
Pro
Sheet Author
Yes, very awesome. I just started playing with your API (or any API really) yesterday & today, so it's great to see an update I was hoping for appear so quickly. I'm excited to Spawn tokens with statuses already on them. I had been using: --bar1|8 to hide information in the token for use in other macros, so I did a double take when I switched to 0.24, and I suddenly had an actual bar. I experimented, and discovered that: --bar1|8/ is how you opt out of the automatic filling of the max field. Thanks for all the work you've put into this. It really levels up my Roll20 experience, and I've barely started playing with it.
I want to create a drop down for players to select from for the type of spiritual weapon they want to spawn but I don't really understand how to do this. Currently, I've created multiple scripts to spawn each type of spiritual weapon, but would like to consolidate all of them into one script. Can anyone help me out with this? Here's what I tried but it didn't work. !Spawn {{ --&name|?{Spawn name?|Spiritual Weapon Battleaxe|Spiritual Weapon Flamehammer|Spiritual Weapon: Flying Anvil|Spiritual Weapon: Scythe|Spritual Weapon: War Pick} --size|0.35,0.35 --offset|1,1 --expand|10,8 }} What I got was the following error: Unexpected argument identifier (&name). Choose from: (name, qty, targets, placement, force, offset, sheet, ability, side, size, order, light, mook, fx, bar1, bar2, bar3, expand, deleteSource, deleteTarget, resizeSource, resizeTarget, rotation, layer)
1642200924
David M.
Pro
API Scripter
--&name is not valid Spawn syntax. Try just --name. You will obviously need character sheets with default tokens set for each of the options. 
Thanks David, yes that was part of the problem, as well as I had : in the character name and it was causing the spawn to fail. Removed the : in the name and now it works.  Thanks again.
1642360388

Edited 1642360850
MAMS Gaming
Pro
Sheet Author
I'm having trouble with adding statusmarkers to the spawned token. Specifically Custom statusmarkers have a string of numbers associated with them, and it took me some experimenting to figure out, but to use your API, I have put the number before the name 1861655:Hinder However, other APIs such as TokenMod & Fetch, put the number after the name Hinder::1861655 I'm trying to use Fetch to take the status from one token, and then use Spawn to create a new token with that status, but since you use different formats, it's not working. Any advice? Would it be possible to get Spawn to accept either input format?
You might be able to do some string manipulation via Script cards to pull the statusmarker from the origin token, transpose the ends, and then reapply to the Spawn. MAMS Gaming said: I'm having trouble with adding statusmarkers to the spawned token. Specifically Custom statusmarkers have a string of numbers associated with them, and it took me some experimenting to figure out, but to use your API, I have put the number before the name 1861655:Hinder However, other APIs such as TokenMod & Fetch, put the number after the name Hinder::1861655 I'm trying to use Fetch to take the status from one token, and then use Spawn to create a new token with that status, but since you use different formats, it's not working. Any advice? Would it be possible to get Spawn to accept either input format?
1642375782
MAMS Gaming
Pro
Sheet Author
Colin C. said: You might be able to do some string manipulation via Script cards to pull the statusmarker from the origin token, transpose the ends, and then reapply to the Spawn. I had not heard of Script Cards. I just looked them up, and have some reading to do. Thanks for pointing me in that direction!
1642377502

Edited 1642377613
David M.
Pro
API Scripter
MAMS: Dang, what you are observing is not intentional. I had forgotten about the double colons used in custom status markers. I believe the issue is that I am currently using a single colon as a delimiter when parsing the --tokenProps command. I'm either going to have to change the delimiter or use a deferral character between the custom marker name & number (e.g. something similar to using %comma% to insert a comma in a tokenProps text field).
1642381728
MAMS Gaming
Pro
Sheet Author
David M. said: MAMS: Dang, what you are observing is not intentional. I had forgotten about the double colons used in custom status markers. I believe the issue is that I am currently using a single colon as a delimiter when parsing the --tokenProps command. I'm either going to have to change the delimiter or use a deferral character between the custom marker name & number (e.g. something similar to using %comma% to insert a comma in a tokenProps text field). Well, I'm glad I could help you find something so soon after publishing the update. Let us know if you figure it out. Colin C. said: You might be able to do some string manipulation via Script cards to pull the statusmarker from the origin token, transpose the ends, and then reapply to the Spawn. ScriptCards is awesome. I'm enjoying figuring out how to make it work. I've figured out how to break strings in it, but I can't seem to figure out how to send them back to other APIs or to normal roll templates.
MAMS Gaming said: ScriptCards is awesome. I'm enjoying figuring out how to make it work. I've figured out how to break strings in it, but I can't seem to figure out how to send them back to other APIs or to normal roll templates. It's very versatile! As to how to feed them back into other outbound calls, you need something like: !script {{ blah blah --~StringVar|string;split;:;[&SourceofStringVarwithStatusmarker] --&NewStatusMarkerString|[&StringVar2]::[&StringVar1] --@apicommand|_parameter|[&NewStatusMarkerString] }} As for reinserting it into a roll template, that's something I've been experimenting with recently also. You'll need at least the ZeroFrame  API. That, plus ScriptCards, and Fetch  you can do something like: !script {{ blah blah --@doesn't matter|{^&template:simple} {{rname=whatever@(Macros|Braces.max) {{mod=whatever the mod is@(Macros|Brace.max) {{r1=[$RollVar]@(Macros|Braces.max) {{normal=1@(Macros|Braces.max) }} You'll need a way to insert the }} for the templates without putting it into the command lines, because that'll break your card. You'll need a place to "store" the }} as an attribute somewhere. I used ChatSetAttr  and a Macros character sheet: !setattr --name Macros --Braces|{{|}}
Hey David, I was creating macros to allow players to spawn light sources like a Candle or a Torch. I also added: --light|5,5 using the Candle example. However, it spawned with 5ft Bright, 0ft Dim. I've tried it on a few tokens and on tokens with settings already saved in the settings to use both Bright and Dim.
1644068101

Edited 1644068484
David M.
Pro
API Scripter
EDIT - I just saw your post in the UDL bug forum, so my LDL assumption below is probably incorrect in which case I'm not sure what's going on. UDL via the api has always been squirrely. Sounds like you are using LDL? 5,5 would mean the Total light is 5ft and the Dim light starts at 5 (which means no dim light would actually be visible). For UDL the first number is Bright light and the second is Dim light. The devs changed how light is defined via api. Also, note if you do use UDL that a bug in the api will not update the dim light number in the token settings tab. From the documentation: -- 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)
Definitely using UDL, I was an immediate adopter. I even ran the Convert Lighting tool just in case there were legacy vales in the marketplace tokens I was using
1644069322

Edited 1644069360
David M.
Pro
API Scripter
Yeah, not sure then. Here's what it looks like when I Spawn a token using --light|5,5 with UDL enabled in my test game:
David M. said: Yeah, not sure then. Here's what it looks like when I Spawn a token using --light|5,5 with UDL enabled in my test game: Yeah, I got the black light sorted at least. Had to toggle LDL on then off again. I may just keep the bright light settings as they are and not worry about the dim
1646525864
David M.
Pro
API Scripter
Sorry for the shameless bump. This thread is about to archive and it gets really annoying to find info across multiple threads.
1646686920

Edited 1646686967
Dumbhuman
Pro
Marketplace Creator
David M. said: Sorry for the shameless bump. This thread is about to archive and it gets really annoying to find info across multiple threads. I'll take shameless advantage of the bump to ask a question... is it beyond the ability of the --ability command to trigger another API Script? For example, on a character named Unarmed Skeleton I've created an ability named MHD which just contains the text !mhd to trigger Aaron's Monster Hit Dice script for randomizing hit points, but I haven't been able to get it to work in any of my Spawn macro tests.  This is the Spawn macro I'm using on a Skeletal Juggernaut (which breaks down into 12 Skeletons when reduced to 0 hit points): !Spawn {{ --name|Unarmed Skeleton --qty|12 --placement|grid 4 --offset|-1,-1 --size|1,1 --side|random --expand|20,30 --deleteSource|yes --sheet|Unarmed Skeleton --ability|MHD }} Everything except the ability call functions as expected.  I can drag a selection around the spawned tokens and click the MHD token action to get their hit points to randomize correctly after that, but ideally I'd like it to be part of the spawn action.  And I know I could probably throw a formula into a bar3 command for these specific skeletons, but ultimately it would be nicer to have the MHD ability on a macro sheet and simply call that for all summons.  Plus which, there are other API scripts that I'd like to be able to call (like Aaron's spin-tokens for some of my spell FX templates). I know you've stated the ability command is finicky, but I didn't see api calls being specifically called out as incompatible so I'm just trying to figure out if the error is on my end.
1646687801

Edited 1646693362
David M.
Pro
API Scripter
I think the primary issue with this is that MHD requires tokens to be selected before running. Newly spawned tokens will never be selected so the MHD script (even on an ability triggered by the Spawn script) doesn't know which token to run on. Unfortunately for your case I think the best course of action would be to use an inline formula for the linked bar as you mentioned.  EDIT - I think I may have written a scriptcard for someone at some point that randomized the hp for various summoned creature types based on the npc_hpformula attribute . I'll look for it this evening when I get home.   EDIT 2 - For the skeletal juggernaut, you could try this macro (requires Scriptcards, SelectManager, and Spawn). Splits it into 12 separate spawn calls, rolling hp for each, and deleting the selected token (the Juggernaut) on the last Spawn. Note there will be a gap between the first and 2nd token rows as written due to some weirdness with offsets on large tokens. If you want them all grouped together, you could start the upper left skeleton as --offset|1,1 instead of 1,0 and adjust the rest accordingly. !script {{ --#hidecard|1 --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|1,0 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|2,0 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|3,0 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|4,0 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|1,1 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|2,1 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|3,1 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|4,1 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|1,2 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|2,2 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|3,2 _bar1|[$hp.Raw]/[$hp.Raw] --=hp|2d8+4 --@forselected|Spawn _name|Skeleton _offset|4,2 _bar1|[$hp.Raw]/[$hp.Raw] _deleteSource|true }}
1646698059
Dumbhuman
Pro
Marketplace Creator
David M. said: I think the primary issue with this is that MHD requires tokens to be selected before running. Newly spawned tokens will never be selected so the MHD script (even on an ability triggered by the Spawn script) doesn't know which token to run on. That's a sensible explanation, thanks.  I figured I was reaching beyond the scope of the script, but it's good to have confirmation at least. I also appreciate the example of a way to get around the issue, but for now I'm probably going to be more likely to select newly spawned tokens and hit a separate !mhd macro than to worry about writing more individualized scripts for multiple scenarios.  Overall this script is really fantastic, so having to select my own tokens after it runs is a pretty small inconvenience.
1647326042

Edited 1647326113
So about the target message we get: Is there any chance we can get an option to put text in there?  Example:  I want to use it to spawn a flaming sphere, can I put the cast range in there somewhere for them?  Or have the field we enter for range, show up in the target box when we're selecting our target @{target|Here|token_id}
1647346869
David M.
Pro
API Scripter
Version Update: v0.25 (Added optional text parameter for --targets subcommand) -  Development gist A quick & dirty update. Optional text can now be provided when using --targets in your macro. The text will appear to the right of the "Select Targets" button and will word wrap after that. Keep your text short if you want to keep it all on one line. Syntax --targets|<#, optional text>     //note this field is comma-delimited. If commas are to be included in Text, use the replacement value %comma% Example 1: Goblin catapult , range 60ft  !Spawn {{ --name|Goblin --offset|1,0 --targets|3, **Range 60ft** //chat output = [Select Targets] Range 60ft (where "Range 60ft" is in bold type) }} Example 2: Goblin shotgun! Why fling one goblin when you could fling 3? We are printing a comma in this example, so must use the replacement value %comma%    !Spawn {{ --name|Goblin --offset|1,0 --targets|3, x3%comma% Range 30ft             //chat output = [Select Targets] x3,Range 30ft        (no bold type - keeps it in one line in my browser) }}
1648105212

Edited 1648105251
Hi all, hope someone can point me in the right direction with an issue I am having. I'm trying to spawn in player character tokens using an Ability macro on another token (using the script of course). My understanding is that the following:  !Spawn {{   --name|Delondra   --offset|1,0   --bar1|@{Delondra|hp_max}/@{Delondra|hp_max}   --bar2|@{Delondra|ac}/ }} Should spawn in the token with the correct values for the bar 1 and 2 with no link to the character sheet.  What I am experiencing is that that bar 1 maintains it's link to the character sheet for one. Additionally, the @{hp} and @{hp_max} attributes on the character sheet are being re-set to their original values from when the default token was attached. In my case @{hp} goes from 13 -> 8 and @{hp_max} from 18 -> 8. Any thoughts?
1648498169
David M.
Pro
API Scripter
Corbin, first of all, apologies for the late response. I was on business travel when I saw your message and it slipped my mind in all the commotion to  test it out and follow up with you. The correct syntax to return the max hp atribute on the 5e OGL sheet is @{Delondra|hp|max} , not @{Delondra|hp _ max}. If you change your macro accordingly then the bar link will be removed as expected.  For spawning PCs, however, I would recommend something along the lines of the following method. This will preserve the current hp of the characters (useful when they are just changing maps mid adventuring day), keep the links in place, and avoid overwriting the character sheet with the values associated with the last time the default token was saved. See this post for some background on this topic. !Spawn {{ --name|CharName --offset|1,0 --bar1|@{CharName|hp}/@{CharName|hp|max} KeepLink --bar2|@{CharName|ac} KeepLink --bar3|@{CharName|hp_temp} KeepLink }}
Thanks David, that worked! I guess my lesson here is not to trust the mouse over representation of the attributes on the character sheet.
Would it be possible somehow to set a freshly spawned token to automatically be "grouped" with the origin/target token?   Use Case:  Friend wants to make a really cool spirit guardians token, I want to make it a very large sized token with transparency and have it move when he moves just like when you group tokens.  
1648605653
David M.
Pro
API Scripter
Hm, I don't think the api can create token groups per se, though if someone knows a way I can look into it. I think it would have to be something like the CarryTokens script, which listens for a certain token's movement and mirrors the location with the "carried" token. This is a bit out of scope of the Spawn script, though, as it doesn't currently have any token monitoring functionality so would be adding another level of complexity. You might try CarryTokens to see if it does what you want. Would be an extra couple clicks, though. From previous forum posts I know you're not a fan of SmartAoE due to your games using a lot of circumstantial modifiers, but it has some options as well. Of course, it doesn't currently do exactly what you're looking for right now. As of now you can have a zone attached to a caster token with no custom art (see Spirit Guardians example from the wiki), or you can use custom art but it's not attached to the character token (see Ice Storm example ). It might not be *too* difficult to merge the two and have the custom art token follow the character around, then use the std SmartAoE triggering if desired. Definitely easier to modify that script to do this than Spawn, as it is already monitoring token movement and writing to the State object to keep track of things, etc. 
I am trying to make a spawn party token that does not spawn the party through walls, I realize thats alot of work so then I decided to just spawn the party's tokens on top of the Party Token, the problem is that no matter what I do, the tokens show up behind the Party Token, is this because I'm the GM and only technically have permissions on the "All Players" token and access to the players tokens via just being a GM?  Will the players tokens always be on top overriding the all players token permission source?   If thats too confusing: Is there a way to send the source token to the GM layer instead of deleting it?