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

Macro in Macro : Random name in token creation

Hello,  This may be a silly question, but I can't seem to use one macro within another. I use TokenMod to create multiple commoners in my campaigns, but I would like to generate the first names randomly.  So I found the namegen API that is really easy to use ( !namegen [language] [boy|girl] ) so i made two macro for it "Random-Boy" and "Random-Girl" But I can't seem to use namegen in TokenMod. the TokenMod macro :  !token-mod {{  --on      flipv      fliph --set      represents|@{Commoner|character_id}      rotation|180      bar1|4      bar2|10      name|#{Random-Boy]      //this is the problematic part//  }} Thank you in advance for your help.
1748577802
timmaugh
Forum Champion
API Scripter
Yep... that won't work. The short explanation is that every "standard" script (like TokenMod and probably the NameGen script) is built as if imagining itself to be a destination script. That is, they are built to expect that if a message uses a command line that meets their syntactic requirements (like starting the message with  !token-mod  for TokenMod)  then that message is *intended* for that script, and the script needs to do what it does with the information in the message. In practice this means that a script (like TokenMod) won't wait for another script (like NameGen) to run, and a script (like NameGen) isn't expecting any other script (like TokenMod) to have anything to do with the message after it's done, so it won't change the message's command line in order to make it so the work is already done before TokenMod gets the message. If you want a longer explanation, you can watch this video which goes into the timing of how scripts work and what differentiates a "standard" script from a "metascript". The good news is that you can still accomplish what you're trying to do with a little setup. All you need are 2 rollable tables (one for male names and one for female names). If you want to get them populated quickly, you can probably harvest names from the NameGen script you found, then use either The Aaron's ImportTable script or my TableToTable script to get them into your game. Imagining that the tables are named "MaleNames" and "FemaleNames", your TokenMod command would look more like: !token-mod {{  --on     flipv     fliph --set     represents|@{Commoner|character_id}     rotation|180     bar1|4     bar2|10     name|[[1t[MaleNames]]] }} You would need a second command line to handle the "FemaleNames" option. Or you could have a query for the table to use, and get by with a single command line. Also, this will do one token at a time. If you wanted to do multiple tokens at a time (and get individual results for each), you can use the Metascript Toolbox (discussed in the video I linked) to accomplish that. If you want to go that route, let me know and I can provide an example.
I understand, the goal was to do this automatically when creating the NPC without creating a table. Is there another option besides creating a table to do this? PS: How do I whisper to my GM with a command like "!namegen”? 
1748616005
timmaugh
Forum Champion
API Scripter
OK, I've twice written long replies that end up getting eaten because the NameGen script is so long and I was trying to include it in my post. The short answer to your question is that you cannot force a script to output/not output, nor to whisper/not whisper that output UNLESS the script, itself, has built-in ways to do that. However, the MetascriptToolbox offers some flexibility, here. I found the NameGen script you were using and updated it to work with the MetascriptToolbox as a plug-in. With this version, you can still access it from the command line like you always would (and have it report to the chat panel the name it generated for you), or you can use it as a plug-in to the Toolbox and have it return the name to the command line so that it will be there when another script (like TokenMod) gets the message. You'll have to get the updated script from  my repo , because the length of the script was causing this message forum to fail and eat my message. Setup Install the MetascriptToolbox (from the 1-click) Delete your current NameGen script and install the new one from my repo Usage You can use it as a stand-alone script the same as you always could, but now you can use it as a plug-in right in the command line of another script and return the generated name. Here it is in a TokenMod command where you are asking for a medieval boy name: !token-mod {{  --on     flipv     fliph --set     represents|@{Commoner|character_id}     rotation|180     bar1|4     bar2|10     name|{&eval}namegen(medieval boy){&/eval} }} If you ALSO want to output the result of the name change, that can be done with further MetascriptToolbox tricks, but since I've already had bad luck with messages getting eaten, I'll wait for you to indicate that you'd be interested before I take the time to demonstrate that.
it works!  you're a genius, thanks a lot for your help! it's going to make my life easier to create the npc my group will find along the way, or workshops or any other npc that isn't plot relevent. Thanks you a lot