
I am trying to figure out why both of the API scripts that I have submitted to Github to the API library fail to load correctly, when both work fine if just pasted into the API screen. Again, if they are pasted into the API screen, they work fine. But if you to to the Script Library and select them, they fail (I will explain how they fail further below). I suspect it might have to do with how I begin and end my API scripts. Roll20 API just seems to concatenate scripts into one long file. However I have noticed that things such as comments and spaces in one script can affect how the next script is interpreted. For example: If one script ends with a comment such as "// end of whatever", then it will treat the first line of the following script as a comment. So rule number one, don't end an API script with a // comment. Years ago I also found troubles if the last line of an API was a /* */ comment, and the first line of the following API was ether an /* */ comment or an // comment. Apparently it was seeing /* *//* */ or /* */// and it was messing up, but I just tested both of those just now, and there does not seem to be any problems, so maybe that got fixed in the last few years. Anyway, I notice that many scripts just seem to begin with a // comment, and the last line just seems to end with a function call without a comment, such as }); All well and good, and I assume that works very well as long as nobody does anything that messes things up. However due to some weird things that I was seeing several years ago, my API's all start with a blank line, then a space, then I do my first // comment. At the end of my file, I always had two blank lines. These work fine if just pasted into the API screen, but I do notice that what I do is different that what anybody else is doing, and wonder if somehow my having blank lines at the beginning and end of my file are what is messing things up. I am pretty sure I am going to resubmit my scripts without the blank lines and spaces and see what that does, but I wonder if anybody has any tips (or horror stories) about how to put your code and comments so as not to mess up any previous or subsequent scripts. OK, here are the specific ways in which my scripts are messing up. Earthdawn by FASA character sheet companion If this script is pasted into an API box, there are no errors. If you go to the Script Library and import it, there are no errors. But if you go to the Script Library and Add it, it says Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: SyntaxError: Invalid or unexpected token Let me just repeat that. If you add the script, you get an error. If you Import the exact same script from the library, it works fine! This is obviously a bug in Roll20, but when I submitted a bug report they moved it to this subforum. A message to <a href="mailto:team@roll20.net" rel="nofollow">team@roll20.net</a> did not get any help. Duplicate and add identifying number to Character and Token Also known as DupCharToken: Again, if you just paste the .js into an API screen and save it, it works fine. But if you go to Script Library, and try to Add or Import it, it just silently fails. It does not give any error message as to why it failed. It does not even give any indication that it did fail. It just proceeds to the next screen without having actually added or imported the .js. And I have no clue as to why it is failing. And like I said, if you just paste the .js in by hand, everything works fine. So anyway, I have checked all the obvious things, and am left checking for maybe it dislikes there being blank lines or spaces at the beginning or ends of files. Any help anybody could give as to what it likes to see, or what in the past has caused it to silently fail to load me would be greatly appreciated.