How do I Reset to Initial Values ?

0 favourites
  • 15 posts
  • Hi All,

    I've tried to do this by myself but got confused during the process so I'm here for help.

    I thought it will be simple for me to do since it's "just" setting values after all... but I got lost every time either with the knobs position or the values where off even when I set them manually... couldn't sync them together like the original initial slider value code.

    .

    I'm trying to have "RESET" button for each slider so it can bring back both Variable and Knob Values to the original / initial numbers that I insert on the Instance Variable "Value".

    Here is an example file, please ignore my disabled attempts (you can remove them)

    DOWNLOAD Example C3 File

    Thanks ahead for any help!

  • The initial value code uses some variables but then these variables change. You need to create some instance variables that don't change to be used as default values. Then you can set the objects back to these original values. Your disabled code doesn't work because those values have changed. If instead it was self.defaultAdjustHSL_Value then it would work and you update another variable self.curAdjustHSL when the sliders move.

  • The initial value code uses some variables but then these variables change. You need to create some instance variables that don't change to be used as default values. Then you can set the objects back to these original values. Your disabled code doesn't work because those values have changed. If instead it was self.defaultAdjustHSL_Value then it would work and you update another variable self.curAdjustHSL when the sliders move.

    Hmmm... so if I'll create EXTRA variables to start with like your example:

    self.defaultAdjustHSL and so on for each of the knobs, it will be possible to address them when pressing the button?

    I'm just trying to see if I understand the logic behind it before I'll be lost again, thanks! :)

  • Yes, for example the knobs have values 0, 50 and 50 that change. You need to store these as another variable and then on reset you set each knob back to those values. You can keep using the current 'Value' variable when the slider changes.

  • I think I got closer by adding the Default variables, but once I got to the code I got lost again...

    can you please have a look and explain how can I clean up my mess? I think it should be more simple and maybe I over do it with unnecessary extra code because I got confused, so it's hard for me to follow the code even when I try to look at every line again and again.

    Thanks ahead for any help! :)

    DOWNLOAD another attempt of mine

  • gofile.io

    I've set a default instance variable directly onto the knob.

    Of course your could also set local variables directly into the code.

    Or use global variables instead.

    But this should work just fine.

  • gofile.io

    I've set a default instance variable directly onto the knob.

    Of course your could also set local variables directly into the code.

    Or use global variables instead.

    But this should work just fine.

    Thanks for give it a try Everade I just had a quick look but it's just resetting the knobs.

    I mean, it doesn't do what I'm trying to achieve which is reset to the Default (initial) values and also put the knobs on the correct position.

  • I'm confused, i thought that's what you were looking for?!

    You said "reset to initial values".

    And that's exactly what it does.

  • I'm confused, i thought that's what you were looking for?!

    You said "reset to initial values".

    And that's exactly what it does.

    First of all I appreciate you're trying to help :)

    Sorry about my bad English, on my original thread I tried to explain what I'm trying to do:

    I'm trying to have "RESET" button for each slider so it can bring back both Variable and Knob Values to the original / initial numbers that I insert on the Instance Variable "Value".

    I wish I could describe it better.

  • Ok i think this is what you want:

    gofile.io

  • Ok i think this is what you want:

    https://gofile.io/?c=rm5mBB

    Thanks again for taking the time, Yes more or less this is the direction but notice if you tweak sliders on one instance than tweak another, when you reset it will tweak also the other instead of only the selected one only.

    Hehe sorry for the mess I'm still trying to solve this without super confusing code and I'm already lost easily...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That's because i didn't touch your code down there. ^^

    Here, fixed that for you.

    Please note that i didn't read myself through your code, so it's absolutely possible that there's still something messed up.

    You should personaly know what you're doing.

    If you can't keep up with your own pace, make sure to add comments to your own code so you understand what's going on, even 5 years later.

    https://gofile.io/?c=VRqIsM

    You can still put that bottom part together with what i wrote to make it smaller.

    --------------------

    Update

    Here's a cleaner version:

    gofile.io

    Enjoy

  • Thank you Everade this is what I was trying to achieve!

    Can you please explain what you did as I'm still a newbie that learning, if you can analyze what you did on specific lines or screenshot for more visual way to explain.

    I'm not just looking for copy/past but trying to learn and understand on the way, thanks for everything! :)

  • Hope it helps.

    To achieve what you want, simply focus first and decide on what exactly you want to achieve.

    In the end it's always the same:

    1. Pick the right object (left side -> events/expressions)

    2. Modify the right variables/values (right side -> actions)

    If you are not sure on how to do something specific, take a look at the manual.

    All the basic things are covered there and should help you to find your way around.

    construct.net/en/make-games/manuals/construct-3/system-reference

    Here you see some connections as of data is being set to which picked object.

    I see at the bottom still some issues, such as the Knob.Value which sets its value to the last selected Knob. But it should give you some idea on what is connected with each other.

  • Thank you so much for the visual and written explanation, this is VERY helpful!

    I will look at it more carefully soon with C3 open :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)