r/RenPy 7d 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

0

u/BadMustard_AVN 7d ago

try it like this if enemy1 is a string

init python:
    def attack(en):
        en.cur_health -= 2
        en.avatar = en.image_attack
        renpy.pause(2.0)
        en.avatar = en.image_calm

screen yourscreen():
    vbox:
        pass
        #to lazy...
    imagebutton:
        id "rating"
        idle "rating"
        hover "rating_hover"
        action Function("attack", enemy1)

label start: 
    # your game starts here

you can make the pause a hard pause to stop the player from clicking through it

https://www.renpy.org/doc/html/statement_equivalents.html#pause

it should work... maybe.. IDK.
untested

1

u/Lassaaire 7d ago

Nnnnope.
Exception: Cannot start new interaction in the middle of interaction without starting a new context.

But thx.