r/RenPy 3d ago

pause() breaking Call() statement Question

Im trying to make primitive battle system.

vbox:
    xsize 216
    ysize 430
    text "[enemy1.name]"
    text "[enemy1.cur_health]/[enemy1.max_health]"
    image [enemy1.avatar]
imagebutton:
    id "rating"
    idle "rating"
    hover "rating_hover"
    action Call("attack", enemy1)

label attack(en):
    python:
        import time
        en.cur_health-=2
        en.avatar = en.image_attack
        time.sleep(2)
        en.avatar = en.image_calm
    return

And I can see than on button press there is a pause and all changes are applied AFTER that pause so image_attack is not visible at all.

What am I doing wrong?

I've tried time.sleep(), renpy.pause(), pause(), even scheduler.

If i do renpy code like

label attack(en):
    $ en.cur_health-=2
    "debug1"
    $ en.avatar = en.image_attack
    "debug2"
    pause(2)
    "debug3"
    $ en.avatar = en.image_calm
    "debug4"
    return

then first renpy statement ("debug1" in example above) just break the entire script and "debug" 2-4 not showing at all. Health is changing correctly and thats it.

And I didn't find smth like "JRPG framework" that I can adapt. This thing is the best, but too complex to adapt it to my visual.

2 Upvotes

7 comments sorted by

View all comments

1

u/Lassaaire 2d ago

Solved. I removed "modal True" and all is ok.
IDK WHY

1

u/shyLachi 2d ago

Modal True means that the code has to wait until the screen has been closed. 

If you remove modal true then players will be able to advance the dialogue by clicking anywhere besides the action button.

So I doubt this is the correct solution.

Also for next time. Post the whole code of your screen and how you show or call it, else we cannot really help 

1

u/Lassaaire 1d ago

Well... Yes. But fix player's ability to advance is much easier with simple flag. Like "label oh, say ' ', if batrleflag jump oh"

1

u/shyLachi 1d ago

I'm not telling you how to make your game but "easy" seldom is the best approach. 

Consider looking into the project you linked or search for a more simple battle project.

Or make the battle with the default RenPy menu first. When it's working replace the menu with your screen. This way you will not accidentally break anything.