The game doesn't continue until the function stops.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
bruzer_
Newbie
Posts: 4
Joined: Fri Jul 19, 2019 6:47 pm
Contact:

The game doesn't continue until the function stops.

#1 Post by bruzer_ »

There is the functinon:

Code: Select all

init python:
    likes = 0
    randlikes1 = renpy.random.randint(7,20)
    randlikes2 = renpy.random.randint(4,17)
    randlikes3 = renpy.random.randint(2,8)
    def likes_grow():
        global likes
        while likes<=113:
            likes = likes + randlikes1
            renpy.pause(3, hard=True)
            likes = likes + randlikes2
            renpy.pause(2.2, hard=True)
            likes = likes + randlikes3
            renpy.pause(3.4, hard=True)
        return likes
That is how I'm calling function in the label.

Code: Select all

label start:
scene black
$ likes_grow()
"[likes]"
"Some text blah blah"
And game just stucks after I call the function until it stops counting . What do I need to make the function work in parallel with the game?
Last edited by bruzer_ on Sat Jul 20, 2019 6:51 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: The game doesn't continue until the function stops.

#2 Post by Imperf3kt »

Remove these lines?
renpy.pause(3.4, hard=True)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

bruzer_
Newbie
Posts: 4
Joined: Fri Jul 19, 2019 6:47 pm
Contact:

Re: The game doesn't continue until the function stops.

#3 Post by bruzer_ »

Imperf3kt wrote: Sat Jul 20, 2019 5:44 am Remove these lines?
renpy.pause(3.4, hard=True)
But I need these pauses between changing of persistent.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: The game doesn't continue until the function stops.

#4 Post by Per K Grok »

bruzer_ wrote: Sat Jul 20, 2019 6:19 am ---
But I need these pauses between changing of persistent.
Maybe you should use a screen instead? That would run without interfering with the game.

Code: Select all


default likes = 0
default randlikes1 = renpy.random.randint(7,20)
default randlikes2 = renpy.random.randint(4,17)
default randlikes3 = renpy.random.randint(2,8)

default timeT=0

screen likesGrow():
    timer 0.2 action SetVariable("timeT", timeT+0.2) repeat True
    if likes<113:
        if timeT<3:
            $ likes += randlikes1
        elif timeT<5.2:
            $ likes += randlikes2
        elif timeT<8.6:
            $ likes += randlikes3

    text "Likes: " + str(likes)
    text str(timeT) ypos 20


This one counts up to fast if you want to end up at 113, but it gives you an idea on how you could do this.

Oh, and use the [ code] tags when showing code. It makes it easier to read. I have probably not understood exactly what you want to do.

bruzer_
Newbie
Posts: 4
Joined: Fri Jul 19, 2019 6:47 pm
Contact:

Re: The game doesn't continue until the function stops.

#5 Post by bruzer_ »

Per K Grok wrote: Sat Jul 20, 2019 6:45 am
bruzer_ wrote: Sat Jul 20, 2019 6:19 am ---
But I need these pauses between changing of persistent.
Maybe you should use a screen instead? That would run without interfering with the game.

Code: Select all


default likes = 0
default randlikes1 = renpy.random.randint(7,20)
default randlikes2 = renpy.random.randint(4,17)
default randlikes3 = renpy.random.randint(2,8)

default timeT=0

screen likesGrow():
    timer 0.2 action SetVariable("timeT", timeT+0.2) repeat True
    if likes<113:
        if timeT<3:
            $ likes += randlikes1
        elif timeT<5.2:
            $ likes += randlikes2
        elif timeT<8.6:
            $ likes += randlikes3

    text "Likes: " + str(likes)
    text str(timeT) ypos 20


This one counts up to fast if you want to end up at 113, but it gives you an idea on how you could do this.

Oh, and use the [ code] tags when showing code. It makes it easier to read. I have probably not understood exactly what you want to do.
Added the code tags.
I thought it's good idea to use the func but your code works succesful, I'll use it. Thank you very much <3

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Toma