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

Uniquely Number New Handouts

I have a script that generates three different kinds of handouts. I would like to have the handouts named Type A #1, Type A #2..., Type B #1, Type B #2..., and Type C #1, Type C #2... How can I accomplish this? The closest I've seen is naming them after a player, such as: DE.name = msg.who + " Dead Location #" + (findObjs({_type: "handout", controlledby: msg.playerid}).length + 1) But when I do this, they all come back with the same name: Joab (GM) Dead Location #1 What I am doing wrong?
1652320810
The Aaron
Roll20 Production Team
API Scripter
Start by verifying assumptions. Are there any handouts controlled solely by that one player? Is that player the sole owner of the newly created handout? controlledby is a comma delimited string of player ids and the special id 'all'. If the handout is controlled by more than one player or by 'all' players, controlledby will not precisely match that one player id.  If you're just basing it on the name of the handout, I'd findObjs() for all handouts, then filter by a regular expression matching the numbered name of the handout you are adding next in sequence, then look at that array length. It's hard to say more without seeing what you're trying to accomplish.