Why getInt is doesn't work ?

  • Hi Алексей,

    That's very strange, I tried running the script in the latest version (2.0.0.2) and it's working for me with no errors.

    Can you let me know what version of Studio you are using, and what operating system? Also, are there any other scripts in your project that could be interfering with this one? Does it occur in an empty project too?

    Hope we can figure this out! The code looks fine and shouldn't cause any problems.

    Thanks,
    Jacob

    Comment actions Permalink
  • 1.7+, win10 , nope, yep

    Comment actions Permalink
  • The PersistentStorageSystem was added in release 2.0 so it won't be available in version 1.7. Can you try in the latest version and see if that fixes it?

    Comment actions Permalink
  • version 2.0+ freeze after one minute of work.

    Comment actions Permalink
  • Hey Алексей, 

    Sorry to hear about the freezing issue. If you can, please file a report if you haven't already and we can try to get that issue fixed.

    PersistentStorageSystem won't work in Lens Studio 1.7, but as long as your Snapchat app is up to date you should be able to push to device and test your lens there.

    You can also adjust your script like this so that it will use a fake version of PersistentStorageSystem if it's not available, to make development easier in Lens Studio:

    var store = (global.persistentStorageSystem && global.persistentStorageSystem.store)
        ? global.persistentStorageSystem.store
        : function(){
            var storage = {};
            return {
                getInt: function(key) { return storage[key] || 0; },
                putInt: function(key, value) { storage[key] = value; },
            };
        }();

     

    Comment actions Permalink
  • Jacob ) hi again!
    can you tell me what is wrong here? 

    My counter show me 1 always. And console show me some strange.

    It seems that is count down to 1

    "

    12:06:31 Tracking restarted
    12:06:31 Loaded score: 0
    12:06:31 tapped
    12:06:31 Current score: 3
    12:06:31 tapped
    12:06:31 Current score: 2
    12:06:31 tapped
    12:06:31 Current score: 1
    12:06:35 Project backup complete
    12:07:35 Project backup complete

    "

     

     

     


    // @input Component.Label tLable


    var store = (global.persistentStorageSystem && global.persistentStorageSystem.store)
    ? global.persistentStorageSystem.store
    : function(){
    var storage = {};
    return {
    getInt: function(key) { return storage[key] || 0; },
    putInt: function(key, value) { storage[key] = value; },
    };
    }();


    var scoreKey = "totalScore";
    var currentGameScore = store.getInt(scoreKey);
    print( "Loaded score: " + currentGameScore);
    function onTap(eventData)
    {
    print("tapped");
    currentGameScore += 1;
    // Store the current score in persistent storage
    store.putInt(scoreKey, currentGameScore);
    // Print the current score
    print("Current score: " + currentGameScore);
    script.tLable.text =''+currentGameScore;
    }

    var tapEvent =!tapEvent ? script.createEvent("TapEvent").bind(onTap) : tapEvent;

     

    Comment actions Permalink
  • Hi Алексей,

    It looks like maybe you set your script to run on "Tapped" instead of "Initialized" in the ScriptComponent?

    You want the script to run only once (on Initialized) so it can set everything up once. The script is already creating a "Tapped" event, so if it runs every time a tap occurs it's always resetting the score and fighting with itself.

    Let me know if that fixes your problem!

    Jacob

    Comment actions Permalink
  • Thank you Jacob it is work great! You really help me with this issue! 

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

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!