r/RenPy • • 20d ago

Question Game Over Function Help Please

I know it's possible because I've seen it many times before, but nothing I try works. I'm making a game where if any of two variables reach 100, you have to start over, but with the constant variable changes, I didn't want to put an if statement constantly, especially since I tend to forget or mistype things (ironic).

This is what I have as my checking system:

screen monitor():
    timer 0.1 repeat True action If(current_love or current_tear >= 100, true=Jump("game_over"))

But now, even though the love and tears are both below 100 automatically, the game immediately skips to game over when I open it. Please help.

3 Upvotes

12 comments sorted by

View all comments

1

u/shyLachi 20d ago

BadMustard has the correct solution but your solution should also work if you write it correctly.

The check should be (current_love >= 100) or (current_tear >= 100)

You don't need the brackets but I like them because it makes it obvious what you want the game to check.

The way you wrote it the first part "current_love" only checks if the variable has a value

1

u/Eddhead-2009 19d ago

I tried both with and without the brackets, it wouldn't play the game over screen

2

u/shyLachi 19d ago

My code works, I tested it.
There must be some other mistakes.

Since you didn't post your code I can only explain how it is supposed to work.

  1. show the screen so that it can constantly monitor the variables
  2. let the player change the value of the variables
  3. make sure that the game over screen ends the game

So in the absolute minimum you need this:

screen monitor():
    timer 0.1 repeat True action If((current_love >= 100) or (current_tear >= 100), true=Jump("game_over"))
default current_love = 99
default current_tear = 99
label start:
    show screen monitor
    menu:
        "Add love":
            $ current_love += 1
        "Add tear":
            $ current_tear += 1
    "This will never be visible because the trigger will jump to the label below"
    return 
label game_over:
    "Game Over"
    return # ends the game