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

Path groups

1392130869
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Can paths be grouped and manipulated as a group with API? Nothing is jumping out at me as I scan the wiki.
1392167108

Edited 1392170089
Matt
Pro
not sure if this is what you're looking for... and I'm just typing out loud... Have two object variables, one that stores lookup info, and one that stores your groups. var Grouping = {}; Grouping.Lookup = {}; Grouping.Groups = {}; When you add a group, create a unique name, we'll use '123'. Add each item to group '123', or by push. Grouping.Groups["123'] = [id1, id2, id3]; Add each item in the lookup table for quick reference, instead of resorting to searching a bunch of arrays. Grouping.Lookup["id1"] = "123"; Grouping.Lookup["id2"] = "123"; Grouping.Lookup["id3"] = "123'; Could use an on("change:graphic") event to capture the object changing, find the group it belongs to from the lookup, and loop through all items in group. Granted, i know you're talking about paths, but looping objects is looping objects... :) on("change:graphic", function(obj) { for (i = 0, i < Grouping.Groups[Grouping.Lookup[obj.get("_id")]], i++) { //do your code for each item } });