Making an automated "while" loop ?

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
Misamor98
Regular
Posts: 45
Joined: Wed Jul 14, 2021 4:43 pm
Contact:

Making an automated "while" loop ?

#1 Post by Misamor98 »

Hi,

For my first project I have been looking into making a clock. For that I have created "calendar" class with a method that adds the specified amounts of seconds to it, and I called this method in a while loop. But when I run the game, the while loop requires clicking to enter a new loop. I would like to make a while loop that doesn't require clicking to loop again, ideally every second. I have looked into timers, but I saw that they worked with the "action" keyword, but it doesn't seem to be usable in python language, and in renpy it doesn't allow calling python methods, so I ran into a wall.

I would appreciate any help :) (my current class and while loop are attached to this topic)
Attachments
WhileLoop.PNG
WhileLoop.PNG (4.18 KiB) Viewed 714 times
Class.PNG

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Making an automated "while" loop ?

#2 Post by Ocelot »

Code: Select all

screen show_calendar(calendar):
    timer 1 repeat True action Function(calendar.AddTime, 15)
    $ text = calendar.Output + "  " + calendar.DayTime()
    label '[text]'

label start:
    # Make sure calendar is set up
    show screen show_calendar(calendar)
    # Text should appear in the top left corner with time.
< < insert Rick Cook quote here > >

Misamor98
Regular
Posts: 45
Joined: Wed Jul 14, 2021 4:43 pm
Contact:

Re: Making an automated "while" loop ?

#3 Post by Misamor98 »

Hey, thank you very much for the quick answer :)

Post Reply

Who is online

Users browsing this forum: No registered users