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

[API Bug?] When on(add:graphic Event happens...

May 26 (11 years ago)
Konrad J.
Pro
API Scripter

I have a on(add:graphic event that checks the object for a specific name and does a few things.  When I copy tokens from one page to another the event fires, but the object past has no name even though the copied object does have a name and when you look at it via the UI after the copy it shows the name.  This would be the normal behaviour for a graphic added, but one that is copied does gets its name after the add so it shuld be passed to the add:graphic event I think.  Just wondering if this is by intent or just a bug?  I need to know the name so I can not do something to some specific tokens, but do something to most others during an add event.

Thanks

May 27 (11 years ago)
Riley D.
Roll20 Team
, but the object past has no name
Do you mean the "pasted" object has no name or are you accessing the prev object and expecting it to have properties?
May 27 (11 years ago)
Konrad J.
Pro
API Scripter

RIley, thanks for getting back to me.  I know you have a busy schedule!

Sorry, typo in the post above I see so it confused you, yes the pasted object. :)

I wrote a script that all it does is on(add:graphic it logs the object added.  When I look in the log it shows the name as "".  But when I actually look at the actual token pasted it does have the name it got from the copied token.  I need to check for a few special tokens with certain names.  If I find them I don't want to do what I normally do to all the other tokens.  But the name comes up "" so I never find these takens to not "process". :)

May 28 (11 years ago)
Riley D.
Roll20 Team

I see.

I think the reason this is happening is because when you "paste" an object, it first creates a copy of the basics of the object, then it actually goes back and "fills in" some of the details like the name. So when the add event is first fired, it doesn't have all the properties yet. That's definitely not how it should work, so I'll see about getting that fixed. It may be a week or two, though.

May 28 (11 years ago)
Konrad J.
Pro
API Scripter

No rush.  Just want to make sure its not me. :)  It will help fix a bug I have with my movement/waypoints script when I also have my graphics defaults script running.  I will be able to exclude the movement/waypoint tokens from getting default values when a graphic is added to the page.

Thanks again!!!

May 28 (11 years ago)

I wonder if this is why I've been having some issues with one of my scripts.