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

That's a good point. I swapped them around and still no joy. Even tried adding in the forselected command in each API call and even tried this in the chat for funsies with Tim's InsertArg script. !ia --chat#CazadorMacro|FlamingSphere --TARGET#@{target|token_id} where CazadorMacro|FlamingSphere is: !scriptcard {{  --#Title|Cazador - Flaming Sphere  --+|TARGET  --@forselected|Spawn _name|SpellEffects _targets|1 _side|1 _order|toFront }}
1617993501
David M.
Pro
API Scripter
Hmm, bummer. Kurt (the scriptcard author) was seeing a similar issue when testing something else. Timmaugh (the SelectManager author) has something in the works to fix the issue, so I'll let you know how that turns out in case you're not following the scriptcards thread. Adding target and/or selected ids to Spawn is something I can put on my list, but there are a couple of other big-ish things I'm trying to finish that are taking up all of my scripting "free time" currently so not sure when I can get to it. Hopefully the SelectManager update will fix your issue in the meantime.   
Sounds great. Thanks for looking into it.
I really wish I could use this API in my campaign but the lack of bar placement access really is such a deal-breaker for me.  I really hope someone with access to ears to the devs has mentioned this fatal oversight on their part after the token UI overhaul cause this is messing with a bunch of ideas I have.  
1618338327
David M.
Pro
API Scripter
DM Eddie: I hear you. It's really distracting when all of your other bars are compact overlapping, but sadly my hands are tied until this gets some attention from the devs. My fingers are crossed with you!
Is there any posibility of adding in the ability to name the spawned tokens?  I'd like to summon my minor illusion token side and name that specific token "Minor Illusion" and same goes for things like bonfire and dancing lights.  Right now they just have an empty name or the character sheets default tokens name.  
1618412211
David M.
Pro
API Scripter
Version Update: v0.19 (added --tokenName command) -  Development gist Allows the token name to be different than that of the default token and/or the character name. Example: !Spawn {{ --name|Giant Ape --size|0.5,0.5 --tokenName|Tiny Tim --offset|1,0 }}
1618424120

Edited 1618424453
David M. said: Version Update: v0.19 (added --tokenName command) -  Development gist Allows the token name to be different than that of the default token and/or the character name. Example: !Spawn {{ --name|Giant Ape --size|0.5,0.5 --tokenName|Tiny Tim --offset|1,0 }} You are awesome!
In your above example for tokenName, I notice that you don't have spaces after the pipes and in my experience with your script there absolutely has to be spaces after those pipes is that just a format lost in a paste issue on your end or has things changed?  No quotes around 2 word names?
1618424850
David M.
Pro
API Scripter
The above syntax works for me. The script performs a trim() on whatever comes after the pipe character, removing any leading/trailing spaces. No quotes are necessary even if spaces exist within the name.
Any chance you could add in functionality for adjusting other parameters of the token like aura setting, etc., like with token-mod? Alternatively, how would I be able to use token-mod on a !Spawn token using the same macro? For instance, if !Spawn could somehow provide the token_id(s) of the Spawned tokens? I seem to remember (*somewhere*) seeing where you could dynamically search the VTT for an object with a particular name and grab the token_id that way.
You could add a macro ability that is a tokenmod command.  You would have to use a different target label in the target system and it'd probably ask for targets twice in some circumstances.  
1618703662

Edited 1618703736
David M.
Pro
API Scripter
Colin, the short answer is it's possible. The other short answer is I'm not sure how far down the rabbit hole I want to go with token settings. There are 53 writeable token properties currently exposed to the api. I'll have to think about this for a bit. I'm also knee-deep in a tricky bit of coding with another one of my scripts that I'm trying to update in the next few days so that is taking a lot of my free time. Re: DM Eddie's suggestion, I was hoping that would work but when I tried it out I got no love. The idea is to use the --ability|<abilityName> command to fire an ability from a character sheet (defined by --sheet|<sheetName> if it exists somewhere besides the selected token's sheet) that would contain the token-mod syntax. For example, I tried using a character named "MacroMule" and added the following ability named "SetAura10Target": !token-mod --ignore_selected --ids @{target|choose target for aura|token_id} --set aura1_radius|10ft Then tried a test Spawn call using the following: !Spawn {{ --name|imp --offset|1,0 --sheet|MacroMule --ability|SetAura10Target }} However, token-mod seemed to ignore the --ignore_selected in the ability and added the aura to my selected token anyway! Probably the presence of the @{target} reference in the subordinate ability screwing things up(?). The token-mod ability works when called directly, but not from the Spawn script. Sad face.  Going back to the original topic: Maybe an easier solution that having me basically replicate all of token-mod within the Spawn script (barf) might be to add something akin to the Scriptcards way to fire an api call. I have all of the spawned token ids at the time of creation. I could store those and then add a --tokenMod command that would read in your token-mod syntax and automatically add the spawned ids and ignore_selected so it would do the stuff to only the spawned token(s). Or maybe make it more generic to add any api call, something like --api|<stuff> . Dunno, just a thought. Like I said, I'll have to think about it a bit when I'm not buried in other projects.
Could nest the token mod command in a chat template instead to get around the instantaneous issues.  I used artwork for my circles and cubes and your script was perfect for it, not sure if thats what Colin wanted the auras for.  Your script is great for a spell template spawner.
I am using this command to spawn my players onto a map around a token I place on the map. !Spawn{{ --name|Roarikk Thorn --offset|-1,0 }} !Spawn{{ --name|Selenia Lochmere --offset|0,-1 }} !Spawn{{ --name|Rossweisse Lochmere --offset|1,0 }} !Spawn{{ --name|Terry-Anne --offset|0,1 }} It works and spawns each of their tokens with proper stats. The problem I am having is since they have reach level 2, their Max & Current HP on their character sheet (OGL 5E) gets reduced (ex. Rossweisse goes from 21 HP to 12, Roarikk from 16 to 10) and their AC drops also as if they are not wearing armor when I spawn them with the API. They have to edit their sheets back to proper HP and uncheck then check their armor they are wearing. I have tested just dragging and dropping their character onto the map and have no problems. If I spawn their token with the API then I have the problem weather I spawn one of them or all of them.
1619435248
David M.
Pro
API Scripter
Snow, check out this post for more background info, but basically you will want to use the KeepLink keyword in a bar override command, like below. This explicitly assigns current values to the token bars of the default token while maintaining the bar links. Obviously, you would replace CharName below as well as double-check which bar goes where for your game's convention. !Spawn {{ --name|CharName --offset|1,0 --bar1|@{CharName|hp}/@{CharName|hp|max} KeepLink --bar2|@{CharName|ac} KeepLink --bar3|@{CharName|hp_temp} KeepLink }}
1619445783
timmaugh
Pro
API Scripter
David M. said: Colin, the short answer is it's possible. The other short answer is I'm not sure how far down the rabbit hole I want to go with token settings.... Re: DM Eddie's suggestion, I was hoping that would work but when I tried it out I got no love.... I could offer another option that might work without a lot of front-end work on your end, David. If you registered Spawn to Plugger (the meta-script that allows you to run scriptlets or full scripts embedded in another script's command line as pre-processing work), then Spawn could return the ids of the spawned tokens (possibly with a user-specified delimiter you could default to be a space -- which is what token-mod expects for the --ids argument). The end result would be that you could then rely on token-mod to handle any of the other token settings/modifications you didn't want to program, yourself. !token-mod {{ --ids {& eval}spawn(--name|Giant Ape  --qty|1 --size|2,2 --layer|object){& /eval} --set aura1_radius|10ft {& select @{target|token_id}} }} The process for registering an existing script to Plugger is documented here . I might step through this process, myself, just to make sure my notes there are accurate (ie, which specific function is registered to Plugger).
Thank you for the help David.
Hi loving this script! Just wondering if there is a way to use a token ID in the --targets command?  Id like to add a spell template to spawn in my spell scriptcards.
1622221711
David M.
Pro
API Scripter
Thanks, Jason! The --targets| command only accepts a numeric value and prints a button to chat to select targets (trying to get around the annoying limitation of the api "forgetting" the selected token when target tokens are also used).  Can you give some more info on what you are trying to do? This script was written before scriptcards or any of timmaugh's meta scripts were around. There might be another solution, depending on what you are trying to accomplish.
im using Kurts Fireball scriptcard and was hoping to have the fireball template spawn on the target for a more visual impact of where the spell has exploded. The scriptcard does the rest but I couldnt figure out how to !Spawn a template at the target.
1622231789
David M.
Pro
API Scripter
Eww, that's a tough one, Jason. The normal syntax for spawning from scriptcards with a target is something like this (assuming you have SelectManager installed): !script {{ --@forselected|Spawn _name|RingOfFire _targets|1 _side|1 _order|toFront }} However, all that extra targeting, etc from the fireball scriptcard is causing problems, and the above crashes the sandbox (not sure which script) :/ I'm wondering if there's some combination of SelectManager & Fetch that can do this, but I'm furiously prepping for my game tonight so can't really follow up until tomorrow. Basically, if there was some way to trick Spawn into thinking the scriptcard's target token is the selected token for Spawn, I think it could work. I should ping timmaugh and see if there's some meta-script wizardry possible.  Of course, the real solution is to have Spawn accept tokenids like you asked about. I'll look into this for the next revision.
1622232450
timmaugh
Pro
API Scripter
Using the new deferral character in ScriptCards, you can do this with SelectManager. Your Spawn line probably looks something like: --@spawn|... Where the ellipsis is the rest of the spawn commands. If you have SelectManager installed and you want to center on a target chosen when you run your ScriptCards macro, you just have to add this to the above line: {^&select @{target|Spawn point|token_id}} That's just an example targeting statement, obviously. You'll need to make it the same as wherever else you need to use it in the ScriptCards macro. ScriptCards will remove that ^, so when the Spawn message is sent from ScriptCards, SelectManager will see that you want to select a token, and you will have provided the correct token ID.
1622232879

Edited 1622232918
timmaugh
Pro
API Scripter
David M. said: I should ping timmaugh and see if there's some meta-script wizardry possible.  Ha! No one expects the Spanish Timquisition. My chief weapon is surprise. Surprise and fear. Fear and surprise. My two weapons are fear and surprise --and ruthless meta-wizardry. My three weapons are fear and surprise and ruthless meta-wizardry.... Amongst my weapons are such elements as: fear surprise... I'll just come in again.
1622233249
David M.
Pro
API Scripter
Haha, thanks Tim. Guess you can ignore the PM I just sent you! :)  
--@forselected|Spawn {^&select @{target|token_id}} _name|Fireball _size|9,9 works perfectly! thanks guys much appreciated
1622258623
timmaugh
Pro
API Scripter
Erik M. said: Hey David,  I am having some trouble with the ScriptCards/SelectManager/Spawn shenanigans.  I'm trying to spawn a spell effect on a target token in a Card. I'm using the forselected command in front of the Spawn call in the Card, but I keep getting: (From API):  No selected tokens to use for that command. Please select some tokens then try again. I was just rereading this thread, and I should point out that the fix I just posted would help with this case, too. Messages that lose their selected tokens because of targeting statements still have @{selected} calls resolved in the command line. That means you can do things like: {& select @{selected|token_id}} ...somewhere in your command line, and you get that one token back as a selected token. You can either do this at the top level of the ScriptCard command, or you can use the ScriptCard deferral to place it in the Spawn call: {^& select @{selected|token_id}} I'm fairly certain, too, that if you go this route, you no longer have to use forselected (since there is only one token selected, and you are making sure it *is* selected, Spawn -- or any other downstream script -- should work. In fact, going without it should be slightly quicker.
Ok, so this script has saved my bacon.  I was hitting my head against the old !summon script. I am having a small issue, though, with the Token Name being cleared when the token is summoned. When summoning individual tokens, this is not a problem since you can just use the --tokenName parameter, but I am having issues when summoning groups of critters (i.e. Conjure Animal).  It seems like if I do not specify a token name, it defaults to clearing the nameplate on the token and eliminating the TokenNameNumber I have so carefully set up for all my NPCs. Am I missing something obvious?
1623380050

Edited 1623380102
David M.
Pro
API Scripter
Nope, sorry that's a recent bug. Version Update: v0.21 (Bug fix for TokenNameNumer compatibility) -  Development gist Looks like the previous update (v0.19, that added --tokenName command) accidentally broke compatibility with the TokenNameNumber script. This version should restore compatibility. Thanks to CatSwann for finding and reporting this bug! (Also, FYI there was a stealth update on Tuesday - v0.20 had added support for non-70px grid sizes). v20 is the current one-click version, so if you need TokenNameNumber support now, you will need to manually install.
Did anything ever come of this? timmaugh said: David M. said: Colin, the short answer is it's possible. The other short answer is I'm not sure how far down the rabbit hole I want to go with token settings.... Re: DM Eddie's suggestion, I was hoping that would work but when I tried it out I got no love.... I could offer another option that might work without a lot of front-end work on your end, David. If you registered Spawn to Plugger (the meta-script that allows you to run scriptlets or full scripts embedded in another script's command line as pre-processing work), then Spawn could return the ids of the spawned tokens (possibly with a user-specified delimiter you could default to be a space -- which is what token-mod expects for the --ids argument). The end result would be that you could then rely on token-mod to handle any of the other token settings/modifications you didn't want to program, yourself. !token-mod {{ --ids {& eval}spawn(--name|Giant Ape  --qty|1 --size|2,2 --layer|object){& /eval} --set aura1_radius|10ft {& select @{target|token_id}} }} The process for registering an existing script to Plugger is documented here . I might step through this process, myself, just to make sure my notes there are accurate (ie, which specific function is registered to Plugger).
1624636210
David M.
Pro
API Scripter
Colin, I was going to work on Spawn this weekend for something else, but I will also look into Tim's Plugger suggestion. Thanks for the reminder :) 
1624642114
timmaugh
Pro
API Scripter
I sent over a proof of concept to David just now as an example, so it is doable. =D
1624643003
David M.
Pro
API Scripter
Thanks, Tim! I was just about to send you a PM myself :)
Nice!
Fantastic!  Confirmed that v0.21 fixes the name of spawned tokens being blank.  Any idea when this version will be pushed to the API Library?  This bug caused all sorts of havok last night.  I saw this post, but made the mistake of thinking this version was already updated on the API Library. David M. said: Nope, sorry that's a recent bug. Version Update: v0.21 (Bug fix for TokenNameNumer compatibility) -  Development gist Looks like the previous update (v0.19, that added --tokenName command) accidentally broke compatibility with the TokenNameNumber script. This version should restore compatibility. Thanks to CatSwann for finding and reporting this bug! (Also, FYI there was a stealth update on Tuesday - v0.20 had added support for non-70px grid sizes). v20 is the current one-click version, so if you need TokenNameNumber support now, you will need to manually install.
1624654297
David M.
Pro
API Scripter
Matt, it should hit one-click on this Tuesday's push.
Hi David, and company. Dont have anything to add, Im mostly a cut-n-paster, but I would like to give a heart felt thanks and shout out to all you marvelous, creative people who come up with these great scripts and give them out for free!...I  certainly appreciate your efforts and I thought you would like to know that. Cheers!
1624885415
David M.
Pro
API Scripter
Thanks Zapatilla, glad you are enjoying it!
Hello, Since 2 days when I load my games I've got this message from the API sandbox : Failed to load SpawnDefaultToken No such file or directory @ rb_sysopen - /code/apiscripts/Spawn Default Token/0.21/SpawnDefaultToken.js
1625137875
David M.
Pro
API Scripter
Thanks for the heads-up, Sebastien. (sigh) One-click currently broken. You can manually install from  here . I really wish there was better data validation when uploading this stuff to one-click. A one-character typo killed the one-click version after Tuesday's release. I've fixed it and resubmitted, but it won't get pushed until next Tuesday's release. Apologies for the inconvenience. 
David M. said: Thanks for the heads-up, Sebastien. (sigh) One-click currently broken. You can manually install from  here . I really wish there was better data validation when uploading this stuff to one-click. A one-character typo killed the one-click version after Tuesday's release. I've fixed it and resubmitted, but it won't get pushed until next Tuesday's release. Apologies for the inconvenience.  No pb ! I just wanted to be sure that you were aware of it :-)
1625590200
David M.
Pro
API Scripter
One-click is live again (v21)! It took a little bit of time between the GitHub merge and when it was active for my games, but it is currently working for me. Let me know if you guys have any issues.
David M. said: One-click is live again (v21)! It took a little bit of time between the GitHub merge and when it was active for my games, but it is currently working for me. Let me know if you guys have any issues. It works !
Is there a way to spawn a token that is "Small" or "Tiny" in dnd 5e standards, in otherwords a decimal point value less then 1 like .75, .75?  or how do I get my small/tiny tokens to spawn without being minimum of medium sized?
1625765442
David M.
Pro
API Scripter
Yes, you can specify decimal values for size, e.g. --size|0.5,0.5 Note that when you move these tokens, they will likely snap to the upper left corner of the grid. If you want to avoid that and remove snapping for the token, then you can optionally turn them into a "drawing"-type token by adding the following command: --isDrawing|true So, for example, spawning a tiny imp adjacent to a selected token: !Spawn {{ --name|imp --size|0.5,0.5 --offset|1,0 --isdrawing|true }}
It seems that v21 is not working with Token Name Number for me any more...
1626747614

Edited 1626749766
David M.
Pro
API Scripter
Cat, does TNN work for you at all, even when bypassing Spawn and pulling straight from the journal? I can't seem to get manual TNN (from one-click, v0.5.14) to work for me right now - it just displays for example "Kobold %%NUMBERED%%". I can't even pull up the help using  !tnn --help EDIT - NM, I reinstalled TNN from one-click (auto-adding libTokenMarkers dependency) and the manual drag/drop is working for me now. I am also able to confirm that v21 is now having issues - it always numbers the spawned token as "<Name> 1". Is that what you are seeing as well? Also, can you confirm that v21 was working for you with TNN before? I might have to ping TheAaron about this to see if there is something I need to change in the call to TNN's public-facing  NotifyOfCreatedToken function.  
TNN was working with !Spawn before. And it is not pulling up <Name> 1, it spawns a token with the name <Name> %%NUMBERED%%. TNN works fine when pulled directly from my library.
1626779596
David M.
Pro
API Scripter
CatSwann, hmm I have one test game that only assigns a "1", and another that spawns with %%NUMBERED%%. The one that always assigns "1" only has Spawn and TNN installed, whereas the other has a ton of scripts, so there is probably some conflicting script shenanigans going on in the latter (and yours?). The "good" news is that if you move the tokens with %%NUMBERED%%, they should get renamed by TNN as Aaron has included an on('change:graphic',...) trigger. I still need to find out why the strange behavior, but hopefully that is helpful in the short term.
Ok, cool. I can live with that.