0 votes

Hi,
i made 2 scenes with 2 buttons to switch between them. In the first scene there is a TextureProgress bar and my goal is to store the information of the bar value at any given time while i switch between the scenes. I made a global script and enabled it on the autoload section of the Project Settings menu, using it as singleton.

The scenes works just fine but the bar progress is not stored and remembered when i switch back from scene 2 to scene 1 where the progress bar is located.

I made some screenshots of the entire test project (it's rather small) and i'm here to ask if someone can help me understand what i'm doing wrong and why the progress bar value isn't stored and remembered. Thank you all.

https://ibb.co/yq15vXY

https://ibb.co/bQYtFst

https://ibb.co/zmFxdy0

https://ibb.co/FggdQZP

https://ibb.co/z6Zn5dF

https://ibb.co/3kTws2y

in Engine by (32 points)

1 Answer

+1 vote
Best answer

I don't see you reading value of bar1 in your Panel.gd script. I only see you writing to it.

Read bar1 in _ready() and use it, unless it's null.

by (2,298 points)
selected by

Hi, thank you for your answer. Could you be so kind to write me down a code sample? I tried but i really don't know how to correctly read and use bar1 on _ready() section of the code. It would be so helpful to me since i'm trying to make this work since January 2018 (i know it's almost unbelievable but it's the truth).

In Panel.gd

func _ready():
    # code you already have in _ready()

    if global.bar1 != null:
        get_node("TextureProgress").set_value( global.bar1 )

Thank you so much! I want you to know that you made my day. All is working now and i can finally proceed to make my little idle game project working as intended. ^^

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.