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 .
×

Moving tokens to spots on a map by attribute

1589390060

Edited 1589390618
Good afternoon!   I'm (16 hours and counting) new to Roll20!  Last week my friend had the idea to try to build out Baseball RPG game on here, and I've spent this time putting the majority of the game here on Roll20!  I was able to build the custom character sheets, and build out enough macros to play the game.  I've figured a lot out, but there are some QoL holes that I'd love to patch up before we start doing more in depth play testing. Question 1)   Is there an existing API that will allow me to have a token with a given property move from wherever it is to a specific location on the map?  I have attr_position (1b, 2b, catcher, cf, SP, RP, etc) as a value in the character sheet.  So what I'd like to do is for a player to select all players, click the 'away team takes the field' macro, and have the players selected who have attr_awayteam checked and who are a second baseman, to move to second base.  (and the 1b would move to first base, and the center fielder to cf, etc.).  I saw I can put GM level objects on the map, and I figure i could name those to use as a destination... I just can't find a working API that accommodates this.   If it doesn't exist, we could certainly work around it, but it'd be tedious. =)  Moving 9-10 tokens per player every 5-10 mins is just, ya know, not great.  So if there isn't an API, maybe ya guys could point me in the direction of an existing API that I could attempt to modify?  or is there somehow a Macro that doesn't require an API for that?  Or, any other ideas you've got! Question 2) I built my macros on the macro screen instead of in a character!  Nuts!  Any easy way to copy them over to a character?  (I just read about this yesterday =P  I can just do copy/paste jobs but figured I'd ask while I'm here if there's a better way) (edit: removed question 3 because I found the answer! thanks!) Thank you guys for your hospitality and advice in advance.  I appreciate the help.
Wow! Super excited to hear that somebody's doing baseball. Huge baseball fan. Aaron's TokenMod would allow you to move all your tokens, and do lots of other cool things too. Then you could set up macros to call certain baseball movements or situations using the tokens. For example, using this command would move a token from wherever it is, to the location 200px from the Top and 200px from the Left of the tabletop: !token-mod --set top|200 left 200 So if that happens to be where 2B is located on your tabletop, you could use that command to put a player on 2B. Gosh, I'd love to chat and see how you're trying to do baseball on roll20.
1589391816

Edited 1589391847
Lots of solutions for Question 1, but this is what I'd do: 1) Consider using Pages to deal with the issue of fielder tokens. For example, make one Page for the "Home" half inning, and another for the "Visitor" half inning. Then simply lay out all the ballplayer tokens once, and switch back/forth to the pages when each team is in the field for every inning. Then you don't have to move the tokens at all. You move the view of the game players instead.
Chris said: Wow! Super excited to hear that somebody's doing baseball. Huge baseball fan. Aaron's TokenMod would allow you to move all your tokens, and do lots of other cool things too. Then you could set up macros to call certain baseball movements or situations using the tokens. For example, using this command would move a token from wherever it is, to the location 200px from the Top and 200px from the Left of the tabletop: !token-mod --set top|200 left 200 So if that happens to be where 2B is located on your tabletop, you could use that command to put a player on 2B. Gosh, I'd love to chat and see how you're trying to do baseball on roll20. AHHH I've been using Tokenmod for setting character names and bars! I LOVE that thing!! I did *NOT* realize I could move tokens with TokenMod!  I'll see if I can make this happen.  That'd be fantastic!  Thank you for the tip!   I'll get a video of the game on Youtube.  I took one last night but I was pointing my phone at the screen instead of screen recording, and the results were.. suboptimal =P Thanks again for the tip!  
Chris said: Lots of solutions for Question 1, but this is what I'd do: 1) Consider using Pages to deal with the issue of fielder tokens. For example, make one Page for the "Home" half inning, and another for the "Visitor" half inning. Then simply lay out all the ballplayer tokens once, and switch back/forth to the pages when each team is in the field for every inning. Then you don't have to move the tokens at all. You move the view of the game players instead. Man.  I was playing around with this !nav teleport tokens API and I had actually built homefield and awayfield variants of the map just a few hours ago haha.  Did NOT occur to me to just duplicate the tokens!  Thinking through it, this will work better than any other possible idea because this way the hitting players can keep their tokens in batting order, and keep the guy who will be up next half inning at the dish or in the 'on deck' circle.  Alright, I'm officially going with this!!  THANK YOU!
1590670775
The Aaron
Roll20 Production Team
API Scripter
If your fields have the same layout, and you're using TokenMod to move tokens, I'd set up a Field player to hold locations. You can then do something like: !token-mod --set left|@{Field|FB}u top|@{Field|FB|max}u To position on First Base. Then you have a single place to set and adjust positions. The trialing "u" means you're setting in Roll20 units, do you can use 15 and 23 instead of 1050 and 1610. Even if you go with different pages to represent top and bottom innings, it would still be useful for set up and resetting.  You might also find it useful using the character id and --current-page: !token-mod --set left|@{Field|FB}u top|@{Field|FB|max}u --current-page --ids @{Glorious Bob|character_id} that way you can move people to position without having to select them, perhaps for a team reset or something.
The Aaron, THANK YOU!  This looks so good and easy to write!!  (I'm hoping it's as easy as that looks!).  I'm gonna take a look at it tonight..  Had some family-health stuff come up and hadn't been able to work at this project for 2 weeks.  I've been struggling trying to work up the ambition to come back.  Seeing your message gives me something exciting and purposeful to work at, and I very much appreciate it. Thanks again, Duaneski
The Aaron said: If your fields have the same layout, and you're using TokenMod to move tokens, I'd set up a Field player to hold locations. You can then do something like: !token-mod --set left|@{Field|FB}u top|@{Field|FB|max}u To position on First Base. Then you have a single place to set and adjust positions. The trialing "u" means you're setting in Roll20 units, do you can use 15 and 23 instead of 1050 and 1610. Even if you go with different pages to represent top and bottom innings, it would still be useful for set up and resetting.  You might also find it useful using the character id and --current-page: !token-mod --set left|@{Field|FB}u top|@{Field|FB|max}u --current-page --ids @{Glorious Bob|character_id} that way you can move people to position without having to select them, perhaps for a team reset or something. 1) The fields do have the same layout, and will continue to for the foreseeable future.  1a) I'd LIKE TO use TokenMods to move tokens, if it's practical and effective. 2) I believe I'm not understanding something about what you've provided.  I built a token named Left Field, placed it in Left Field, added attr_fieldlocation, added lf as an option for that attribute.  But not understanding how this works together. I've got the macro: ( have tried a few iterations, I'm not really sure which fields I need to change in this code!) !token-mod --set left|@{Left Field|fieldlocation}u top|@{Left Field|fieldlocation|max}u I tried searching TokenMod documentation for some reference to FB.  I'm thinking you meant that as First Base.  But not 100% on that.  Assuming you meant First Base, would I then need to make each field position its own attribute?  I could do that, but not understanding what in TokenMod makes a token move to the identified token.    Importantly, I don't know if it's possible but what I think would be necessary is a macro that looked for matches anyway..  Like there isn't much improvement between: - click on Left Fielders Token - Click left field macro button (UI would be absurdly cluttered with the placement buttons if I needed 9+ anyway) versus - click on left fielder's token - drag and drop in left field. Is it possible to have a macro that looks at all selected players for their position, and moves them to a spot on the map based upon their position attribute?  (example: I select all 10 players on my team.  DH is moved to area identified as Dugout, 1B is moved to 1B, SP is moved to pitcher's mound, etc..) (If that's what you provided, then I'm sorry I'm just not getting it!  Any more insight on how to build that would be appreciated.  If I just need to keep plugging away, I'd appreciate even that much insight =P And if that's really not possible - I know there's some big limitations on IF/THEN statements by nature of the type of code used.. So I was thinking this probably isn't possible...  But if it is, I want to do it!) Either way, thanks again!, Duaneski