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

How to assign an existing rollable table to a token using Token-Mod?

February 10 (4 years ago)

Edited February 11 (4 years ago)

I am hoping to create a macro that when called will add some flavor and depth to my game. I wanted to create a macro that generates NPCs, in a way. I'd want their name to be randomized from specific tables I've created, such as Vistani Male First Names, Barovian Female First Names, or Noble Last Names. Once you'd have the names randomized, I'd like to have the token roll from the corresponding rollable table. If you have a Vistani Man, you should roll his appearance from the Vistani Male table to determine his apperance. Here's the rub. I can only roll on that table if the token is already corresponding to that table. Is there any way to use Token-Mod to say "Set this token to use the rollable table "Noble Females" and set the current side of the token to random"?


Naming Every NPC:


I'm playing Curse of Strahd (this post is entirely going to be spoiler free). In this game, there are a lot of Vistani and Barovian commoners. Rather than naming them Commoner 1, Commoner 2, etc, I wanted to name them based on some rollable tables. I have some rollable tables (for organizational reasons, they're named is a super Yoda-esque way. "Name-First/Last-Nationality-Gender". (Example: [[1t[Name-First-Barovian-Male]]] [[1t[Name-Last-Barovian]]]). So I made a macro that assigns these random names, randomize the image on my rollable table of commoners, and set up the token bars and token actions.

My macro to accomplish this is as follows:


!token-mod {{
    --set
        name|"[[1t[Name-First-Vistani-Male]]] [[1t[Name-Last-Vistani]]]"        
        Vistana-Man,currentside|*
        bar1_link|npc_ac
        bar2_link|npc_speed
        bar3_value|@{selected|HP|max}
        bar3_max|@{selected|HP|max}
}}
!ta

For the purposes of keeping it all organized, I have this macro, and others like it nested in a Macro called "Randomize Names"

/w gm &{template:default} {{ name=Name Randomizer }} {{ Vistani Names=[](!
#Name-Randomizer-Vistani ) }} {{ Barovian Name Randomizer=[](!
#Name-Randomizer-Barovian ) }} {{ Elf Name Randomizer=[](!
#Name-Randomizer-Elf ) }} {{ Dwarf Name Randomizer=[](!
#Name-Randomizer-Dwarf ) }}

This Macro should create a list of buttons I can press. Each of these buttons call a different macro based on region/race for the names.


Clicking one of those buttons yields a more specific list that breaks those down by male/female and whether or not the last names can be randomly generated or if they need to be pre-determined. (Normally I hate doing this, but you only need to do this once)

/w gm &{template:default} {{name=Vistani Name Randomizer}} {{Random Last Name= }} {{ [Vistani Male Names](~NameGen|Vistani-Male-FL) }} {{ [Vistani Male Names](~NameGen|Vistani-Male-FL) }} {{Predetermined Last Name= }} {{ [Vistani Male Names](~NameGen|Vistani-Male-F) }} {{ [Vistani Male Names](~NameGen|Vistani-Female-F) }}



At this point, if you select a token, you should be able to click one of those buttons to change its name to a random name (or by request of my DM in one of my games, to use a pre-determined last name, as in the case of a families.) 

But the use case is larger than just naming every NPC in the world. It's also useful for hiding the identity of Vampires or Bandits. Perhaps you don't want your players to know that the tokens surrounding them are bandits or vampires. You should be able to click the "Vistani Male Names" button to change your vampire to show a typical, mundane Vistani name AND change the token to look harmless and mundane as well. (no vampire teeth in the token). 

The Problem:

I'd like to be able to say that this token should use the "Vistana-Man" rollable table for its images, and I'd like to set the current side of that table to a random side. Is there any way to say "Change the token's image to the [Vistana-Man] rollable table in a macro? (I'm hoping to basically tokenize a rollable table with images and to use that token on the @{selected} token."

If it can't be done in a macro, can I get some help on how to do so via an API call? I have no idea how I'd even begin to assign a Rollable Table from My Collections tab to a token. Randomizing the side is trival, 


If I could get this working, I'd want to be able to select a bandit's token and click "Randomize-Name"


February 10 (4 years ago)

Edited February 10 (4 years ago)

If @TheAaron could grace this post with his divine knowledge, I'll donate my player's souls to charity. But mostly, I'd just appreciate the help.

February 10 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hahahahaha!

So, this isn't currently possible, but I think it could be added without too much trouble.  I like the idea of saying "pull all the images from this table", I'd just need to come up with a reasonable syntax for doing that.  I'll see what I can come up with.

February 10 (4 years ago)

Wow, thanks TheAaron. I swear, you must have a red landline that rings you whenever someone asks a macro related question. Whole corporations have slower response times!

I kinda figured there wouldn't be a way to do this with macros, since it runs counter to the normal work flow of creating tokens.

But I'd appreciate it. I'd normally just write a script to do this, but Javascript isn't really my primary coding language, let alone the fact that I wouldn't know where to get the values of tables in my collections tab to begin with!

Thanks a million!