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 .
×
May your rolls be merry + bright! 🎄
Create a free account

[Script] Snap on paste

How to I make things snap on paste? So I can cut my map making time in half?
1435001283
The Aaron
Pro
API Scripter
There isn't a setting, but you could make an API script that would align graphics to the grid on create.
Ugh fine, just please tell me there is a step by step tutorial on making api scripts.
1435030510
The Aaron
Pro
API Scripter
There isn't really. There are some Javascript tutorials out there and there is information about the API on the wiki. I was working on writing a Roll20 Javascript API Tutorial with my wife as the test pupil, but haven't really gotten so far on it yet. However, I did have a few minutes to solve this problem for you! MapSnap: v0.1.1 Commands: !map-snap --on : Turns on MapSnap !map-snap --off : Turns off MapSnap !map-snap --toggle : Toggles on/off state of MapSnap !map-snap --help : Shows the help page for MapSnap Currently, it will snap anything copy/pasted to the 70 pixel grid. A later version will support other sized grids, so let me know if you need that. GIT: <a href="https://github.com/shdwjk/Roll20API/blob/master/Ma" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Ma</a>...
1435030627
vÍnce
Pro
Sheet Author
The "Codenator" strikes again. :-)
1435030808
The Aaron
Pro
API Scripter
hahahahaah.. What does that make you? (don't break it yet, I *JUST* made it!) =D
1435051428
Ziechael
Forum Champion
Sheet Author
API Scripter
Hate to nitpick but 'provides a mode durning which' may contain a spelling error ;) Nice functional script though =D
1435067482
The Aaron
Pro
API Scripter
Everyone's a critic! I'll fix that for version 0.1.2. :)
Wow, just like that and you have it. Thanks! I suspect that give you a year and every possibly api makeable will be made by you.
1435071369
The Aaron
Pro
API Scripter
Hehehehe. I'd certainly give it a try. The problem is finding time in that year while working a full time job and raising 7 kids. :) When I become independentmy wealthy, I'll just write API scripts all day long. =D
Maybe they'll hire you on as a full time api manager at double whatever you are currently making. :p
1435076773
The Aaron
Pro
API Scripter
Unlikely, I make pretty good money at this point. =D But here's dreaming! Really, I'd probably move for comparable compensation.
If they suddenly hire you after this post I should get managorial royalties.:)
1435092828

Edited 1435092963
There is something a bit off with the snap on targetting. Everytime I paste an item it shifts to the left. Any chance you could make it so the code just auto grabs and let goes so the game's auto snap on takes control? Or mimic that effect? Not complaining though I am still really grateful for it as I just need to paste to the right of my target for it to work.
1435094340
The Aaron
Pro
API Scripter
I can probably do something to make it easier. Currently the way it works is: ( Math.floor(( X -( W/2 ))/70) *70 )+( W/2 ) The 70 is the size of a grid. Objects X,Y location are based off the center of the object, so this takes the X, subtracts half the width to get to the left edge, then divides that by 70 (dropping remainder with floor) to get the number of tiles over that this point is in, then multiplies by the size of tiles again to get to where the left edge is aligned on a tile boundary, then adds half the width back in to get to where the center point has to be to maintain that left alignment. The X,Y that it has when you paste is vaguely nebulous. Certainly if you click first, it's right where you clicked, if you didn't, it is "probably" where your mouse is at the time, though if you've scrolled with the mouse wheel, that's not quite right. Probably changing to Math.round() would make it feel more natural. I'll give that a try...
1435096356

Edited 1435096401
I actually was clicking, I click then control+v. Maybe its because I am pasting a 2 by 2 square? Because I noticed that if I click just right of the center lineit works correctly, if I click just left it shifts to the left.
1435096914
The Aaron
Pro
API Scripter
Yeah, I was testing with a 2x2 and it did feel a bit strange, but wasn't sure where that strange was. I'll try a few iterations (or if you wanna slide down to line 121/122 and change the Math.floor( to Math.round( on each and see how it feels... Could try Math.ceil( also. ).
okay I'll try that. But tomorrow
1435116368
The Aaron
Pro
API Scripter
Actually, I just tried it and it felt better to me. I updated to version 0.1.2 with round instead of floor
1435156099

Edited 1435156356
Just out of curiosity, what do those terms mean? And yeah now it seems if I click exactly 50% it shifts correctly instead of going left.
1435156390

Edited 1435156425
The Aaron
Pro
API Scripter
Floor() = Always round down Ceil() = Always round up (ceiling) Round() = Round up for .5 or more, down otherwise Input Math.floor() Math.round() Math.ceil() 1.3 1 1 2 1.5 1 2 2 1.7 1 2 2
Oh well so it really doesn't matter then a whole lot then. So yeah round is good. How is it that the system does their own auto snap? They seem to work off what percantage of the square is already filled.
1435187652
The Aaron
Pro
API Scripter
Good question. Did you try the rounding version?
yes I did I also tried making top floor and left cieling and all the other variations. I settled on round for both as it was the simplest. One more thing though even bigger thenthis well by a lot, as this is easily worked around by just remembering. For some reason if I actually paste really fast, like to fill in a floor, the api doesn't work. Is that just their server?
1435194450
The Aaron
Pro
API Scripter
Hmm. Good question. I'll try that out when I'm not stuck in a car and see if I can duplicate the behavior and log some details. Regarding round, if you can give me an idea of where you're clicking and where you expect it to end up, I can adjust the algorithm. Something like a screenshot with the graphic where it ended up, a red box of the same size where you wanted it to go and a green box around the area you want to click in to get it there would be perfect.
It's not something that simple. You see with a 4 by 4 orb bigger I normally paste by clicking in the center of where I want it. Obviously my clicking g isn't robotically perfect. So sometimes I click dead on sometimes a little to the left or right what have you. The natural result is the Ali will slide in the Wong dire tion sometimes. Can't be helped. Though roll 20s native system seems to work via percent so it doesn't have that issue.
1435195868
The Aaron
Pro
API Scripter
Well, if you notice a pattern, like it always sliding left, I can bias the calculation to move to the right, like only subtracting a 3rd of the width. Just let me know. :)
I think I'll be more concerned over how it doesn't seem to activate when too many tiles are placed. :/
1435269022
The Aaron
Pro
API Scripter
I'll try to take a look at that tonight. Sorry for the delay!
just did single squares for the first time. Yeah doing that biasing the calculation to the right might help.
I had to zoom in to 50% but I even got e hag of pasting the single square tiles. And I was wrong, its not that it doesn't auto move the tiles, its just rather slow. A 2-3 hundred tile room can take a bit to finish.
1435552178
The Aaron
Pro
API Scripter
Not too much I can do about that, I'm afraid. Has to do with the sandbox communication, so out if my control. :/ How is it otherwise? Anything need changing?
1435565447
Ziechael
Forum Champion
Sheet Author
API Scripter
Hope you don't mind Devlin, but i'm going to move this to the API forum and slightly amend the title to reflect that this is now an active script should others be interested in using it.
Fine to both. Its functional and once one gets used to the quirk of needing to always paste in the lower right quadrant of the square/squares you want the token/tile to enter. It works fine. Still saves a lot of time. :) And ultimately that is what is important.
1435596646
The Aaron
Pro
API Scripter
I'll see if I can do something about that pasting...
1435604785

Edited 1435611679
You would have to probably radically rewrite it. Its probably not worth the effort.