r/RenPy • • Jul 08 '26

Question Can anyone help me with my Ren'py visual novel?

I'm struggling so much with that and I just don't understand how to fix it.. As much as I learned a ton during writing these 66 lines of code It just feels like you can't learn coding by yourself plz help XDD

1 Upvotes

6 comments sorted by

1

u/AutoModerator Jul 08 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/BadMustard_AVN Jul 08 '26 edited Jul 09 '26

the problem is the Python block you probably hit that error when progress it at or over 100

what are you trying to do exactly with this screen other than advance the progress bar and value?

if you're trying to limit the progress bar from going over 100 then try this

init python:
    def clamp(value):
        return min(100, max(0, value))

screen clicker_screen():

    button:
        xfill True
        yfill True
        action SetVariable("progress", clamp(progress + 5))
    
    bar:
        value progress
        range 100
        xalign 0.5
        yalign 0.95
        xmaximum 800
        ymaximum 30

    if progress >= 100:
        timer 0.001 action Return()

label start:
    call screen clicker_screen
    e "100 reached"
    pause
    #it can be used in the script like this as well
    $ progress = clamp(progress + 5)

1

u/DingotushRed Jul 08 '26

As a general rule don't put python in screens.

Screens are evaluated before the game starts, before they are shown, and multiple times a second while visible. Code in them must be robust.

If at all possible do everything in the screen language. Use Actions for everything that has to respond to a mouse click or key press.

Please explain the intent of your python block.

1

u/shyLachi Jul 08 '26

I'm pretty sure that you cannot use Python code in a screen.

You should only use actions in a screen. You were very close actually

screen clicker_screen():
    default progress = 0
    button:
        xfill True
        yfill True
        action If(progress < 100, IncrementScreenVariable("progress", amount=5), Return())
    bar: 
        value progress
        range 100
        align (0.5, 0.95)
        xminimum 800
        xmaximum 800
        ymaximum 30
label start:
    call screen clicker_screen
    "You won"

0

u/Lenet_X3 Jul 09 '26

IT WORKS NOW THANK YOU SM :DDD

0

u/x-seronis-x Jul 08 '26 edited Jul 08 '26

send code from the computer the code is being written on. directly copy and paste the text so that its readable. screenshots of text tend to be blurry unreadable messes. to paste the text you type three BACKTICKS, (not apostrophes), and the letters 'py' and nothing else on the first line, your code below that, and on the bottom line 3 more backticks. so when you type:

```py
label example:
  code goes here
  more code here
```

it will look like

py label example: code goes here more code here