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

Method to drag a character to the map?

1409329556

Edited 1409330405
I'm working on creating characters through chatbox input, and I'm nearly done. What I presently lack is a good way to get a character dragged over onto the map. So the current process would be... 1) Run '!createme Name' 2) Drag from Character pane to map. 3) Run '!setme (data)'... Can I roll '2' into '1'? Here's 'createme': on('chat:message', function(msg) { if(msg.type == 'api' && msg.content.indexOf('!createme ') != -1) { var name = msg.content.substring(9); var curPageId = Campaign().get("playerpageid"); var character = createObj('character', { name: name, bio: '', gmnotes: '', archived: false, inplayerjournals: msg.playerid, controlledby: msg.playerid, avatar: '<a href="https://s3.amazonaws.com/files.d20.io/images/5356582/kSzAxQqNOBlRlEKPRwKlUg/thumb.png?1409327289" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/5356582/kSzAxQqNOBlRlEKPRwKlUg/thumb.png?1409327289</a>' }); }; }); Thanks Aaron for the formatting tip
1409329996

Edited 1409330054
The Aaron
Roll20 Production Team
API Scripter
Hit the paragraph button with the code highlighted and choose 'code' from the drop down: It's probably best to separate your code from other text by a blank line on either side before changing it to code. The editor can do some wonky things otherwise. You can then remove the whitespace. You can go back and edit your existing posts and add the formatting back in. There isn't a way to access what token a character uses from the API (much requested feature recently). Note the difference between the token a character uses ( set on the character sheet and not accessible to the API ), and tokens that represent a character ( set on the token settings and accessible to the API ) What you CAN do is look through all tokens for a token that is associated with it and already on a map page, then create one with it's settings on some other page.
There's got to be something, if only maybe nothing presented to the API. If I drag from the character window to the map, it does everything I need automagically. So something is aware of how to build the connections between the two.
1409334304

Edited 1409334341
The Aaron
Roll20 Production Team
API Scripter
You can build the connection from the token to the character by setting the 'represents' property on the token to the character's id. You cannot access what the character has configured as it's token or any of the character's configured tokens' state. So, for example, if you knew that you wanted a particular token image to represent a given character, and you knew that you wanted each of the 3 bars to represent specific attributes on the character, you could create a graphic, with that token, and set it's 'represents' to the character id, then set the 'bar1_link', 'bar2_link' and 'bar3_link' to the attribute id's for the attributes you want them to represent. That would give you a token that represents the character, with bars tied to and adjusting attributes on the character. It would not give you the token configured in the character to represent it. It would not have all the settings of that token, just whatever settings you apply to it. The Roll20 system certainly knows how to create those tokens, but that is not exposed to the API. That is why I suggest finding tokens that represent the character already on a page. For example, there is someone in the suggestions forum asking for a way to group PCs, specifically to be able to add the PCs to a map automatically. You could get this behavior from the API like this: Create a loading page Place all your Players' Character on that page. Create a script that has the page id for the loading page Make the script respond to some command ( !addgroup perhaps ) which does the following: Find all the tokens on the Loading Page (the Party) Find all the tokens on the Player current page Remove from the Party any tokens whose characters already have representations on the Player current page Create new tokens on the Player current page with the same settings as each of the remaining members of the Party. Hopefully that clears things up?