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

'Unexpected Token' error when adding second script

1391189724

Edited 1391189774
Matt
Pro
I completed my first shot at an API script, and it seems to be working fine, even over long periods of time. I went to start a new script, and I keep getting the error 'Unexpected Token )'. Not sure if I'm missing something, or if there's any special requirement for adding additional scripts - I'm still relatively new to the feature. I get the error on the following script: on("change:graphic", function(obj) { log(obj.get("name")); }); If I change the script to be on a single line, i do not get an error, but it does not seem to execute when a token is changed. on("change:graphic", function(obj) { log(obj.get("name")); }); If I disable the first script, the second script works fine in both variations listed above. As others seem to be running multiple scripts without incident, I'm hoping it's something simple I'm missing. Any ideas?
1391202421

Edited 1391203136
DXWarlock
Sheet Author
API Scripter
Not sure why its doing it, if I copy the first script, it works fine for me. it returns '"Flint" on a character named Flint for me. Second one same for me, it works and returns '"Flint" Is there something in your other scripts causing it? Usually the disabled script is the culprit if an error goes away. What is your first script you are referring to by If I disable the first script, the second script works fine in both variations listed above.
I deleted the above script, and proceeded to add a different script. I receive no errors this time around, but have done nothing different. My first script is still enabled, and all is working as intended now.
1391262042
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
try on("change:graphic", function(obj) { log(obj[0].get("name")); });
I ran into this problem as well, but getting Unexpected Identifier. I have figured out the cause though, you need to end the function with a semicolon like in Stephen's example. Even though I didn't think about it at the time, the reason for this is basic JavaScript syntax. Just make sure you end all of your functions with the semicolon.