Call variable every increment

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By blueapollo

I have a button that increases a variable by 1 every click, and I want a sprite to show everytime on the 15th increment clicks (15th, 30th, 45th, etc.).

I’m doing something like this. I know it’s wrong, but I just don’t know the right way of doing it.

func _on_stepButton_buttonPressed:
> var step += 1

if step == step + 15:
> print("Hello there")


:bust_in_silhouette: Reply From: jgodfrey

You’re looking for:

if !step % 15:
    print("Hello there")

Or, perhaps more beginner friendly (but the same as above):

if step % 15 == 0:
    print("Hello there")

jgodfrey | 2023-02-20 03:33

Sorry for the late reply, just got to try it out and it works! Thank you!

blueapollo | 2023-02-25 14:29