(Solved) Creating an Increasing and Decreasing Temperature Mechanic

I’m trying to create a temperature mechanic. The idea is that the normal setting is 15C. When the AC is turned on, the temp decreases. When the AC is turned off, the temp increases back to 15C. I managed to make the decreasing function, but it won’t change when I turn on the AC. What could be causing this?

This is the setup I have on the main page. I also have a Pause Temp Timer action for the Beginning of Game condition.

This is in an External Event and it’s the AC mechanic.

So what is the question?

I think this is the question:

A few checks:

  1. Do you initially set the value of the global variable Temp to 15 somewhere, and are there conditions for that to ensure it only happens once?
  2. Do you have temperature increase functionality? If so, could this be interfering with the temperature decrease?
  3. Does the AC animation changes to whatever animation 1 looks like?
  4. Have you tried changing the Timer check to every 1 second, rather than 15, and see if anything happens?
  5. Is there anywhere else in your events that you are stopping the scene timer “Timer”?
1 Like
  1. Yup! For the Beginning of Game condition, I have the global variable set to 15. I don’t think I have anything to make it so that it only happens once, though. Would that just be setting adding a Trigger Once command somewhere, or would I have to do something different?

  2. No, I only have the decrease mechanic programmed right now.

  3. Yup!

  4. Timer check? I’m not sure how I would do that. I’m still a beginner with Gdevelop.

  5. I checked my code over and no. The only places where there’s a pause Timer for Temp is what I’ve shown in my first post.

Also, thanks for waiting for my response. Life has been a bit hectic.

For 4, change the condition to 'The timer "Temp" is greater than 1 seconds", because 15 seconds is a while to wait for a variable to change. Does the temperature plummet?

1 Like

Hey, it works, now! I changed it like you said and the temperature slowly drops when I turn the AC on. Thanks for that!

Now, I just need to figure out how to make it so that, when the AC is off, the temperature returns back to 15.

I’m gonna fiddle with this, but I’m open to any more suggestions, guys!

I’d be tempted to check if the timer is paused and the variable Temp < 15, and raise Temp if so.

1 Like

Okay, I’ll try that and reply again in a few mins.

This is what I tried, but it didn’t work. I also tried putting the Timer Paused condition as a sub-condition of Timer Greater Than 1 condition, but that didn’t work, either.

Anything you think I could change?

Your check for the paused timer doesn’t make sense. As the variable Temp decreases, GDevelop is going to check on a timer named “15” on object Temperature. Then it’ll check for a timer named “14” on object Temperature. And so on.

You should be checking the scene timer “Temp”.

Also, if you reset the timer named “Temp” when it’s paused, it’ll just set it back to 0. At which point the check that timer “Temp” > 1 second will always be false, and Temp will never get decreased again.

Changes to make (delete all those with a red line through them):

1 Like

I did that and the timer increases when paused, now, which is what I want. It wont stop increasing, though, so there needs to be a way for me to stop the timer from increasing past 15.

Do that in the first event of the screen snippet in my previous thread.

1 Like

The global variable condition? Okay.
Should I make a sub event to try and cap the timer at 15?

No, just pause the timer along with the other actions that pause the object timer.

Alternatively, in the event where you’ve changed the object timer to a scene timer, add a second condition that checks the value of Global Variable Temp < 15.

Either way will work.

1 Like

Adding another timer to the other actions didn’t work, but adding the second condition with the scene timer condition worked great!

The mechanic works great, now. Thanks again for your help, Mr. Men!
I’m still tinkering with the numbers, so I’ll post the finished code later on tonight or tomorrow.

1 Like

I’m afraid that I might forget to post this tomorrow, but here’s what the programming mechanic looks like when working (and linked to the At the Beginning condition along with the button mechanic).

There were a couple more tweaks I wanted to do, but I may not have the time tomorrow.

Hello, sorry to bother you, but, I have been looking at this thread to learn about how to make a temperature mechanism and it seems quite incredible, the truth is, the mechanism to alter temperature have you thought of making it your own Extension? My personal opinion would say that it would be a pretty good development tool! But that is your decision! Thanks for this thread so I can learn more about the commands and implement it in my project!


That sounds like a cool idea. I won’t be able to do it anytime soon due to real life stuff. The mechanic isn’t perfected either, so I’d need time to revisit it and tweak it some more.

Ok, I don’t steal that, just i recomended this because are good 4 all👍🏻(sorry for my bad english, now i can’t use translate)

1 Like

It’s a great idea! Thank you for suggesting the idea.
I know you won’t steal the idea. :ok_hand:

(I didn’t know you weren’t fluent in English. I’m sorry if I said anything that was confusing.)