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

Some help with paths

Hoping someone can point me in the right direction. I am trying to work out where a scattering object (a thrown grenade) strikes a wall on the Dynamic Layer. I've got a function to work out where two line segments intersect (and if they do), basically working out where the thrown grenade (1st line segment - from the thrower to where it lands) hits another line segment (which would be a wall segment). My problem is I'm a little lost on figuring out how to access the points of the Dynamic Layer walls to create that 2nd line segment. I've looked at the Kaboom script to try and get some inspiration, specifically (pageid is defined earlier in the script): // Returns an array of all paths on the dynamic lighting layer const findWalls = function (pageid) { wallArray = findObjs({   layer: 'walls',   _type: 'path',   _pageid: pageid, }); // This is to make the array nice and find out where the points actually are var completePointArray = _.map(wallArray, function (wall) {   const pathTuple = JSON.parse(wall.get('path'));   const transformInfo = PathMath.getTransformInfo(wall);   const pointArray = _.map(pathTuple, (tuple => PathMath.tupleToPoint(tuple, transformInfo)));   return pointArray; }) return completePointArray; }; Not sure how the data is arranged and how to access it. I'd like to be able to use it to run my intersection function (which likely duplicates another function in PathMath) - getting the left,top of each point (Only using line segments to define walls on the dynamic layer) Any help appreciated.
1583754074
The Aaron
Roll20 Production Team
API Scripter
The Path objects store their point data in the path property. It's JSON encoded and follows the SVG path format.&nbsp; Path object (Roll20):&nbsp; <a href="https://wiki.roll20.net/API:Objects#Path" rel="nofollow">https://wiki.roll20.net/API:Objects#Path</a> SVG Path Specification:&nbsp; <a href="https://www.w3.org/TR/SVG/paths.html" rel="nofollow">https://www.w3.org/TR/SVG/paths.html</a> Be sure to transform the points to be relative to the position of the Path object.&nbsp;
Perfect, thanks, got it working and incorporating walls into a few other scripts (one for flamethrowers and one for ranged weapons fire) Who knew high school math would come in handy!
1583921726
The Aaron
Roll20 Production Team
API Scripter
Great!