The forum on this site is closed for new comments and posts. Continue the conversation in our Snap AR Discord server.

"Script is undefined"

  • Comment actions Permalink
  • Are you double clicking the script inside lens studio or just in your file browser? If in your file browser: It appears you have the same problem I had where windows script host is set by default in all new windows 10 installs to run JS files. But it doesn't even support them so you just get an error. Try right clicking and open it with something else.

     

    However this shouldn't prevent the lens from being uploaded.

    I tested out your script and I got an error in the console. To fix it I had to change the last line to this:

    myAnimation.getMaterial(0).getPass(0).baseTex.control.play(1,0);
    Comment actions Permalink
  • @Apoc When using the 2 arguments I get the following error:

    01:03:22    Error: Wrong argument number count, expected 1, got 2
        at [anon] () native strict preventsyield
        at [anon] (Script:8) preventsyield

    It is when opening the file in Lens Studio itself, I can still edit the text file fine even when the error occurs. I have never had this problem until I reverted back to factory settings on this laptop. It still works fine on my PC. I'll try upload it with your change to the last line even though it gives an error for me, as that might be what is giving the error on Snapchat's end.

    Comment actions Permalink
  • Hi Callum King,

    Like Brandon said, it sounds like the javascript file is being opened up by an external program, probably Windows Script Host. When you double click a javascript file in Lens Studio, it opens that file through your operating system, which will use whatever program is associated with .js file extensions. You can ignore that "script is undefined" error message in this case, since it's coming from an external program that doesn't know how to handle scripts meant for Lens Studio.

    If you want, you can change your default program for ".js" files to your text editor of choice, like Visual Studio Code or Sublime Text. That way, double clicking on script files will open them in a text editor instead of trying to execute them. Here's a guide for doing that on Windows (step 4 is the relevant part): https://support.microsoft.com/en-us/help/4028161/windows-10-change-default-programs 

     

    For the script error you guys are discussing, it sounds like Callum is using a video texture and Brandon is using an animated texture :)
    The play method on AnimatedTextureFileProvider takes 2 arguments, while the play method on VideoTextureProvider takes 1 argument. So the 1 argument version will work as long as the texture is a video texture.

     

    I'm not sure what could be causing your submission to fail. Can you tell me the Lens ID for this Lens, found in the "My Lenses" panel? I can get back to you with more information about why the submission is failing.

    Comment actions Permalink
  • Hi Jacob,

    Thanks for the detailed response! I will change it on my laptop when I next get the chance.

    That makes much more sense! I have the VideoTextureProvider yeah with the texture set as the video! :)

    For the issue, I could now easily recreate it on my PC but I'm curious about the error. Here's the lens ID: 93521406-5d4e-4396-9c9e-7ed37dd23b70

    It's only a very simple lens that was requested by a Reddit user.

    Comment actions Permalink
  • Hey Callum King,

    Thanks for providing the ID. It looks like the Lens was rejected due to an error from playing a video texture from an invalid state. You can try doing a check like this to make sure the video isn't told to play if it's already playing:

    var provider = myAnimation.getMaterial(0).getPass(0).baseTex.control;

    if (provider.getStatus() != VideoStatus.Playing)
    {
    provider.play(1);
    }

    Hope this fixes it for you, let me know if it doesn't. Sometimes errors like this show up during the review process but are hard to reproduce on your own. It might be caused by touch input occurring immediately when the Lens starts or something like that. 

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!