We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
Accept
Advertisement Create a free account

TokenMod setting bar_1/2/3_link not working

1593444592
I'm trying to create a simple macro that sets the attributes of a token i have already manually set to represent a particular mook character sheet but when i try and run it the results or sporadic, this is the code I'm using: !token-mod --set bar1_link|npc_speed bar2_link|npc_ac bar3_link|hp bar3_reset|1 bar3_link| Essentially what i'm trying to do is make a macro that sets up the default token for a mook character sheet the way i like it. Setting speed and AC for two of the attributes and setting the max and current of attribute 3 to the hp but then clearing the link. What happens is sometimes it doesn't do anything, other times it applies the previous character sheet i'd set the token to represent and sometimes it gets it right but in all circumstances it clears the name field completely which i also don't want. This is just the first bit of what i'm trying to do, really what i want is for it to also see if the mook character has darkvision and change those settings accordingly but not there yet, also if the %%NUMBERED%% text could be slotted in at the beginning of the name that'd be good but as at the moment i seem to be causing the name to be blanked out i'm not hopeful. I'm sure all this is down to me doing something stupid but i can't see what, if i'm missing something or if this whole thing could be done using an existing API feel free to point me in that direction. Thanks
1593445609
The Aaron
Forum Champion
API Scripter
Can you post your full command text?  Also, in the cases where it seems to be pulling from the previous character, can you verify that the token is linked to the right character, probably by shift-double-clicking it.
1593509543

Edited 1593509788
That is the full extent of the macro code i've written, what i do is a find a monster from the compendium (srd) and drop it onto my map, obviously it comes up as just the blank sillouette which i then delete, i then find a token i like that suits the monster i'm making which i drop onto the map, i then set that to represent the monster. At this point what i usually do is then change the attributes to bar_1 = npc_speed bar_2 = npc_ac bar_3 i set to the average hp in both current and max but don't link it I then set the DL settings to match monsters senses (darkvision etc.), the nameplate to be visible and add %%NUMBERED%% to the beginning of the name. Then i set that token to be the monsters default. What i'm trying to do is make that into a macro, but it doesn't seem to quite be working. The macro is stored in my macro character as an attribute. *I just tried it again having freshly loaded and launched my game and the code above is currently not doing anything whether i run it from my macro sheet or written direct into chat. **I feel very much like i'm missing something obvious and i'm gonna feel dumb when it's pointed out to me. ***On that note, can anyone suggest a good place to start learning how to make APIs? I've got quite a bit of experience with VBA for excel but even that is entirely self taught and i'm completely at see with anything else.
1593522071
The Aaron
Forum Champion
API Scripter
For the above process, this works for me: !token-mod --set bar1_link|npc_speed bar2_link|npc_ac bar3|@{selected|hp|max} (bar3 sets the current and max values) Adding in the numbered name and saving it as the default token: !token-mod {{ --on showname --set bar1_link|npc_speed bar2_link|npc_ac bar3|@{selected|hp|max} name|"%%NUMBERED%% @{selected|npc_name}" defaulttoken }} For learning to write APIs, start with learning Javascript.&nbsp; Javascript for Cats is a nice fun intro/refresher:&nbsp; <a href="http://jsforcats.com/" rel="nofollow">http://jsforcats.com/</a> &nbsp; Once you're done with that, I suggest reading Javascript: the Good Parts by Douglas Crockford .&nbsp; It's an older book (Pre ES5), but it's still great for honing down your Javascript to the things that are best to use from the basic language.&nbsp; While you're learning, keep in mind that Roll20 APIs run in a sandbox, not the browser. There is no DOM, and all of your interactions will be asynchronous and event based.&nbsp; It shares more in common with a Node module than a browser app.&nbsp; Here are three posts on Roll20 that talk a lot about writing scripts: <a href="https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern" rel="nofollow">https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern</a> <a href="https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1</a> <a href="https://app.roll20.net/forum/post/6237754/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6237754/slug%7D</a> And here's Nick Olivo's YoutTube playlists, he has a bunch of API tutorials that are a nice starting point and he adds more all the time:&nbsp; <a href="https://www.youtube.com/user/NicholasOlivo/playlists" rel="nofollow">https://www.youtube.com/user/NicholasOlivo/playlists</a>
1593525010

Edited 1593525191
It's still being really screwy, it seems almost like it carrying commands over from the previous chat. It's hard to explain but for example I have another really basic macro that uses token-mod to flip on or off showname (basically so that i can let my players see what the monsters are called during combat for ease of stating who they're targeting but the rest of the time i can just press a button to hide them) and now thats not just switching between showname being on or off for the selected token but also overriding the name with '%%NUMBERED%%[mook i was testing newNPC macro with]' and also removing the represents for that token. I'm guessing this is to do with a dodgy interaction between token-mod and another API maybe? I can add you to my game and make you GM if you wanna take a look but i'm sure you don't wanna get that involved :-) code for nameplate macro: !token-mod --flip showname
1593525369
The Aaron
Forum Champion
API Scripter
Actually, yeah, can you PM me a link?&nbsp; I would like to figure out what the issue is so I can either fix it or at least be aware of it for mitigation in future cases.