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

[Help] New Scripts Not Working, Smell Test Failed

After finishing my first entrance animation, which I was surprised I got working in the first place, I've started on my second but quickly hit a brick wall. Based on the original scripts that work but with new parameters and variable names, I added some new functions that returned the Unexpected identifier and Unexpected var token errors. After going through as much debugging as I could, I decided to take a step back. I copied the original entrance sequence, changed the chat event trigger from "!entr1" to "!entr2" and disabled the original. "Unexpected identifier". There shouldn't be any problem here. Nothing else has changed. Nothing else depends on the chat event but this.
What campaign is it? I'll take a look.
1368472189
Konrad J.
Pro
API Scripter
Here are a few things I've been dong to help my code work better. :) &nbsp;The JSLint is&nbsp;definitely&nbsp;worth it to find all your missing { and ; Something I have found useful for making sure I have all the ;, {, ) in the right place is&nbsp; <a href="http://www.jslint.com/" rel="nofollow">http://www.jslint.com/</a> Go all the way to the bottom under Options you can set the Tolerate options to true if you like for "missing 'use strict' pragma", "many var statements per function", and "messy white space". paste your completed script into the window it tells you to. &nbsp;Press the JSLint buttom below this window. &nbsp;Have a look at all your errors. Errors You Can Ignore 'sendChat' was used before it was defined. Only worry about this kind of error if its a function you &nbsp;wrote. &nbsp;The rest or Roll20 and the JSLint checker doesn't know about any Roll20 stuff. Unexpected dangling '_' in '_type'. Again if this is in a line referencing something for Roll20 then ignore this error. Another thing I like to do is look at others code to get ideas and find out how to write certain things. Also don't use the Roll20 editor. &nbsp;I'm using Notepad++ now and it works great. This is a good article... <a href="http://www.w3.org/wiki/JavaScript_best_practices" rel="nofollow">http://www.w3.org/wiki/JavaScript_best_practices</a> Try not to use cryptic variable names. &nbsp;Too short is just as bad as too long!
Magic or Riley? It works even though I changed nothing. Thanks, Konrad. Started using Notepad++, and JSLint tells me I'm bad at this. *Without changing anything, it fixed itself then broke itself again...&nbsp;Infinite loop or long running process detected. **It works now/again. I'm gonna go sit in the corner and mumble for a while.
1368486544
Konrad J.
Pro
API Scripter
Melvin McSnatch said: Magic or Riley? It works even though I changed nothing. Thanks, Konrad. Started using Notepad++, and JSLint tells me I'm bad at this. *Without changing anything, it fixed itself then broke itself again...&nbsp;Infinite loop or long running process detected. **It works now/again. I'm gonna go sit in the corner and mumble for a while. JSLint is very strict, you can learn to ignore certain things. &nbsp;They even have an article about not feeling bad if JSLint tells you your code is bad. &nbsp;It doesn't mean anything personally and it doesn't mean it won't work. &nbsp;THey are just trying to enforce the best practices. Your futureself will thank you when you have to come back to your code later! &nbsp;But its great for finding all the { and ; I'm always missing! &nbsp;I'd learn to use it, especially on long code with lots of Ifs and nests. &nbsp;I have had a similar experience to you where it works and then another time it complains. &nbsp;I think its because your code is missing something and you just get lucky sometimes with it ignoring certain things that are needed. &nbsp;I've had code work that have missing and too many ;. Put it through JSLint until you only get complaints about functions not being definned and you will be happier!