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

[functions] map_coordinates|map_adjacent

1468976459
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
<a href="https://gist.github.com/BaldarSilveraxe/74f8ae208a" rel="nofollow">https://gist.github.com/BaldarSilveraxe/74f8ae208a</a>... Two functions....&nbsp; map_coordinates gives the column and row on the map for a graphic (Aaron helped me with the hex part a while back.) ... map_adjacent (which uses&nbsp;map_coordinates) gives a list of ids for all adjacent graphics... organized by clockwise position: I needed this for a script I am playing with, others might find it useful (or find my mistakes.)
1468980843
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
oooohhhh, That looks very useful Stephen. I've been trying to think how to institute automatic token moving between maps for Page Navigator. This could be rather useful for that. I'll have to dig into them and see if I can utilize them.
You have it checking for adjacent... should be able to do some math magic and make it scalable per the map scale and target a variable distance from the center.
1469010679

Edited 1469011984
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Yea.. you could also do "patrol" movement and check for crossing a DL path at each "step" or doors or bumping into things.. And if you are a very optimistic person... you could hope that this would end "flanking" debates when playing with Aaron (but I think that is a stretch.)
1469028825

Edited 1469028843
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey Stephen, The following definitions from map_coordinates: left_h = 46.48512749037782, top_h = 39.8443949917523, left_step_h = 69.585127490378, top_step_h = 39.84439499, left_v = 37.5992809922301, top_v = 43.8658278242683, left_step_v = 37.5992809922301, top_step_v = 66.9658278242677; Do they define the size of essentially a cell in the columns/rows?
1469030047

Edited 1469030220
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Yes. That is the values Roll20 uses to construct hex maps (V and H)..... squares are 70 (in both direction.) So if you give the function a graphic object the function looks at the page grid setting and returns the column and row for the graphic.
1469030478
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Awesome, thanks
1469416307
Gold
Forum Champion
Hi Stephen. Is this the script that I would want to use for setting up certain art-packs that have, say, 16 tiles that should be arranged 4x4? Here is the other thread with some examples of what I'm trying to do presently, <a href="https://app.roll20.net/forum/post/3689220/live-on-" rel="nofollow">https://app.roll20.net/forum/post/3689220/live-on-</a>...
1469444742

Edited 1469444895
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Gold said: Hi Stephen. Is this the script that I would want to use for setting up certain art-packs that have, say, 16 tiles that should be arranged 4x4? Here is the other thread with some examples of what I'm trying to do presently, <a href="https://app.roll20.net/forum/post/3689220/live-on-" rel="nofollow">https://app.roll20.net/forum/post/3689220/live-on-</a>... I would do something different with those. Something like this script.... <a href="https://app.roll20.net/forum/post/655402/script-ra" rel="nofollow">https://app.roll20.net/forum/post/655402/script-ra</a>... The idea would be....Whenever you place one of those tiles (your pack) the tile gets sized and dynamic lighting.... and the lighting updates whenever you move or spin the tile. It would be a straight foreward URL detection script. The code in this thread is more for something like this GIF below (click image to see animation.)
1469445474
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
This is actually closer to what you need: <a href="https://app.roll20.net/forum/post/1746279/script-d" rel="nofollow">https://app.roll20.net/forum/post/1746279/script-d</a>... Since you are not Aaron or Vince I will help.... I will send you something tonight.
1469617127
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Click for animation... still working out the tiles and interface... but looks promising as a hex mapping tool.